-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
55 lines (53 loc) · 1.46 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
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
// Entry point for js bundles.
entry: {
main: [
'webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port
'webpack/hot/only-dev-server', // 'only' prevents reload on syntax errors
'./src/main.js'
]
},
// Use source-maps.
devtool: 'source-map',
// Output to dist/main.js
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
// Plugins for hot-reloading and copying over the index.html file.
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/index.html'),
inject: false
})
],
// Dev server set up. Serve from dist directory.
devServer: {
contentBase: './dist'
},
// How to resolve imports. Use src/ and node_modules/ as roots.
resolve: {
root: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'node_modules')
],
extensions: ['', '.js', '.jsx']
},
// Handle js, jsx, scss files with webpack loaders.
module: {
loaders: [{
test: /\.jsx?$/,
include: path.join(__dirname, 'src'),
loaders: ['react-hot', 'babel-loader']
}, {
test: /\.scss$/,
include: path.join(__dirname, 'src'),
loaders: ['style', 'css?sourceMap!sass?sourceMap'],
}]
}
};