-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
64 lines (62 loc) · 1.57 KB
/
webpack.config.js
File metadata and controls
64 lines (62 loc) · 1.57 KB
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
require('dotenv').config()
const path = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')
require('@babel/register')
module.exports = env => ({
entry: ['@babel/polyfill', './src/index.js'],
mode: env.NODE_ENV,
output: {
path: path.resolve(__dirname),
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
port: 8080,
contentBase: path.join(__dirname),
historyApiFallback: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization'
}
},
plugins: [
new HTMLWebpackPlugin({
template: path.join(__dirname, 'index.html'),
inject: false,
filename: 'index.html'
})
],
module: {
rules: [
{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
emitError: true,
failOnError: true
}
},
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader']
},
{
test: /\.(woff2?|ttf|gif|svg|eot|otf|png|jpg)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader'
}
]
},
optimization: {
minimizer: [new TerserPlugin()]
},
watch: env.NODE_ENV === 'development',
watchOptions: {
poll: true
},
devtool: 'inline-cheap-module-source-map'
})