This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.dev.js
105 lines (92 loc) · 2.69 KB
/
webpack.config.dev.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const webpack = require('webpack');
const path = require('path');
const appPath = path.join(__dirname, 'app');
const distPath = path.join(__dirname, 'dist');
const exclude = /node_modules/;
const CleanPlugin = require('clean-webpack-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const DashboardPlugin = require('webpack-dashboard/plugin');
const config = {
context: appPath,
devtool: 'source-map',
entry: {
app: './app.js',
vendor: ['react', 'react-dom']
},
output: {
path: distPath,
publicPath: '/',
filename: 'bundle.[hash].js'
},
plugins: [
// Generate index.html with included script tags
new HtmlPlugin({
inject: 'body',
template: 'app/index.html'
}),
// Remove all files in dist before creating a production package
new CleanPlugin(['dist']),
// Do not output to dist if there are errors in webpack
// new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
$_ENVIRONMENT: JSON.stringify(process.env.NODE_ENV)
}),
new webpack.optimize.CommonsChunkPlugin(
/* chunkName: */ 'vendor',
/* filename: */ 'vendor.[hash].js'
),
new DashboardPlugin()
],
module: {
loaders: [
{
test: require.resolve('react'),
loader: 'expose?React'
},
{
test: require.resolve('three'),
loader: 'expose?THREE'
},
{
test: /.jsx?$/,
exclude: exclude,
loader: 'babel'
},
{
test: /\.html$/,
loader: 'file?name=[name].[ext]',
},
{
test: /\.css$/,
loaders: ['style', 'css?root=' + appPath + '/assets']
},
{
test: /\.scss$/,
loaders: ['style', 'css?root=' + appPath + '/assets', 'sass']
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
exclude: exclude,
loader: 'url?limit=1000&name=assets/images/[hash].[ext]'
}
]
},
devServer: {
contentBase: './app',
colors: true,
noInfo: true,
historyApiFallback: true
},
resolve: {
root: [
path.resolve('./app'),
path.resolve('./app/components'),
path.resolve('./app/redux'),
path.resolve('./app/assets')
],
alias: {
config: path.join(__dirname, 'config', process.env.NODE_ENV)
}
}
};
module.exports = config;