This repository has been archived by the owner on Apr 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
62 lines (58 loc) · 1.55 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
const CleanWebpackPlugin = require('clean-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const styles = require('./webpack/styles');
const uglify = require('./webpack/uglify');
const images = require('./webpack/images');
const html = require('./webpack/html');
const json = require('./webpack/json');
const babel = require('./webpack/babel');
const common = (PATHS,isDebug) => merge([
{
entry: {
main: ['babel-polyfill', PATHS.source+'/index.js']
},
output: {
path: PATHS.build,
filename: "bundle.js"
},
devtool: 'source-map',
devServer: {
compress: true,
port: 5050,
hot: true,
https: false
},
resolve: {
alias: {
styles: PATHS.build
}
},
plugins: [
new CleanWebpackPlugin(
[PATHS.build]
),
new webpack.DefinePlugin({
_DEBUG: isDebug
}),
new webpack.HotModuleReplacementPlugin()
]
},
]);
module.exports = (env = {}) => {
const isDebug = !env.release;
console.log("isDebug",isDebug);
const PATHS = {
source: path.join(__dirname, 'src'),
build: path.join(__dirname, 'build')
};
return merge([
common(PATHS,isDebug),
styles(PATHS,isDebug),
babel(PATHS,isDebug),
html(PATHS),
images(isDebug),
json(),
]);
};