-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
74 lines (71 loc) · 1.91 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
74
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const HOST = process.env.HOST || 'localhost';
const PORT = process.env.PORT || '5000';
module.exports = {
context: __dirname,
devServer: {
contentBase: './dist',
// do not print bundle build stats
noInfo: true,
// enable HMR
hot: true,
inline: true,
port: PORT,
host: HOST
},
devtool: 'eval',
entry: [
`webpack-dev-server/client?http://${HOST}:${PORT}`,
`webpack/hot/dev-server`,
'./src/index.js'],
output: {
path: `${__dirname}/dist`,
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js']
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|dist)/,
loaders: ['babel']
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
}
]
},
// Entry point for node-sass files
sassLoader: {
includePaths: ['src/styles/index']
},
plugins: [
// Enable stylelint plugin to lint scss files
// By default, the build WILL fail if there are any errors
new StyleLintPlugin({
syntax: 'scss'
}),
// Define node environment to be 'develop'
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('develop')
}
}),
new webpack.NoErrorsPlugin(),
// Enable hot module reload
new webpack.HotModuleReplacementPlugin(),
// Generates a base html
new HtmlWebpackPlugin({
template: './index.html'
})
]
};