-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
68 lines (58 loc) · 1.56 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
const path = require('path');
// plugins
const ExtractTextPlugin = require("extract-text-webpack-plugin");
// Helpers
const { paths, flags} = require('./utils');
const plugins = require('./webpack');
const { IS_DEV, IS_PROD, IS_WATCH } = flags;
const { BASE_DIR, DEV_DIR, DIST_DIR, PUBLIC_DIR, ENTRY_POINT } = paths;
const { common, development, production } = plugins;
module.exports = (env) => {
return {
cache: IS_DEV,
watch: IS_WATCH,
devtool: IS_DEV ? 'source-map' : false,
entry: {
app: [path.resolve(BASE_DIR, 'src/index')],
},
output: {
path: DIST_DIR,
publicPath: PUBLIC_DIR,
filename: '[name].js',
},
module: {
rules: [
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/, options: { "presets": ["env"] } },
{
test: /\.(css|scss)$/i,
loader: ExtractTextPlugin.extract({
use: [{
loader: 'css-loader',
options: {
minimize: IS_PROD,
sourceMap: IS_DEV,
},
}, {
loader: 'sass-loader',
options: {
minimize: IS_PROD,
sourceMap: IS_DEV,
},
}],
fallback: 'style-loader',
}),
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.json', '.css'],
},
devServer: {
contentBase: DIST_DIR,
historyApiFallback: true,
},
plugins: IS_DEV ?
[...common, ...development] :
[...common, ...production],
}
}