-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
90 lines (88 loc) · 2.3 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
// var BrowserSyncPlugin = require('browser-sync-webpack-plugin')
module.exports = {
entry: './src/index.ts',
devtool: 'inline-source-map',
watchOptions: {
ignored: /node_modules/
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg|jpg|gif|mp4)$/,
use: [
{
loader: 'file-loader',
options: {
name: "[path][name].[ext]",
context: 'src'
}
}
]
},
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: '/node_modules'
}
]
},
// compilerOptions: {
// target: "es5",
// //this config for target "es5"
// lib: ["webworker", "es5", "scripthost"]
// //uncomment this for target "es6"
// //"lib": ["webworker", "es6", "scripthost"]
// },
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new CleanWebpackPlugin(),
new CopyPlugin([
{ from: 'rawFiles',
to: 'assets',
context: 'src'}
])
// new BrowserSyncPlugin({
// // browse to http://localhost:3000/ during development,
// // ./public directory is being served
// host: 'localhost',
// port: 3000,
// server: { baseDir: ['public'] }
// })
],
devServer: {
// Display only errors to reduce the amount of output.
stats: "errors-only",
// Parse host and port from env to allow customization.
//
// If you use Docker, Vagrant or Cloud9, set
// host: "0.0.0.0";
//
// 0.0.0.0 is available to all network devices
// unlike default `localhost`.
host: process.env.HOST, // Defaults to `localhost`
port: process.env.PORT, // Defaults to 8080
open: true, // Open the page in browser
},
resolve: {
extensions: ['.tsx', '.ts', '.js']
}
};