-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.dev.config.js
72 lines (70 loc) · 1.76 KB
/
webpack.dev.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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const GLOBALS = {
'process.env.NODE_ENV': JSON.stringify('dev'),
'process.env.BUILD_ENV': JSON.stringify(process.env.BUILD_ENV),
__DEV__: true,
};
module.exports = {
resolve: {
extensions: ['.js', '.jsx', '.json'],
},
devtool: 'cheap-module-eval-source-map',
entry: [
'./src/webpack-public-path',
'react-hot-loader/patch',
'webpack-hot-middleware/client?reload=true',
path.resolve(__dirname, 'src/index'),
],
target: 'web',
mode: 'development',
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'bundle.js',
},
watch: true,
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 500,
poll: 1000,
},
module: {
rules: [
{
test: /\.js|.jsx$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
},
{test: /\.css$/, use: ['style-loader', 'css-loader']},
{test: /\.less$/, use: ['style-loader', 'css-loader', 'less-loader', 'postcss-loader']},
{
test: /\.(jpe?g|png|gif|ico)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
],
},
],
},
plugins: [
new HardSourceWebpackPlugin(),
new webpack.DefinePlugin(GLOBALS),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({
template: './src/index.ejs',
minify: {
removeComments: true,
collapseWhitespace: true,
},
inject: true
}),
],
};