-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
73 lines (63 loc) · 1.92 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
const webpack = require('webpack');
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const nodeEnv = process.env.NODE_ENV;
const isProduction = nodeEnv !== 'development';
// Common pluginslet plugins = [new webpack.DefinePlugin({'process.env': {NODE_ENV: JSON.stringify(nodeEnv),},}),new webpack.NamedModulesPlugin()];
if (!isProduction) {
plugins.push(new webpack.HotModuleReplacementPlugin())
}
const entry = isProduction ? ['babel-polyfill', path.resolve(path.join(__dirname, './index.js'))] : ['webpack/hot/poll?1000', 'babel-polyfill', path.resolve(path.join(__dirname, './index.js'))];
const TerserPlugin=require('terser-webpack-plugin');
module.exports={
entry:'./index.js',
output:{
filename:'bundle.js',
path:path.resolve(__dirname,'./dist'),
publicPath: "/public/"
},
resolve: {
fallback: {
"fs": false,
"tls": false,
"net": false,
"path": false,
"zlib": false,
"http": false,
"https": false,
"stream": false,
"querystring": false,
"url": false,
"util": false,
"url": false,
"crypto": false,
}
},
mode:'none',
module:{
rules:[
{
test: /\.js(x?)$/,
exclude: /node_modules/,
loader: "babel-loader"
}, {
test: /\.json$/,
exclude: /node_modules/,
loader: "json-loader"
},
{
test:/\.(jpg|png)$/,
exclude: /node_modules/,
use:['file-loader']
},
{
test: /\.css$/,
exclude: /node_modules/,
use: ["style-loader", "css-loader"],
}
]
},
plugins:[
new TerserPlugin()
]
}