-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
102 lines (98 loc) · 2.74 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
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
'use strict';
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const cwd = process.cwd();
const config = {
entry: {
app: path.join(cwd, 'frontend/app.js'),
vendors: []
},
devtool: 'cheap-module-source-map',
output: {
filename: '[name].bundle.js',
sourceMapFilename: '[file].map',
path: path.join(cwd, 'public'),
publicPath: '/'
},
resolve: {
root: [
path.join(cwd, 'src'),
path.join(cwd, 'node_modules'),
],
moduleDirectories: [
'node_modules'
]
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
},
{
test: /\.html$/,
loader: 'file?name=[name].[ext]',
},
{
test: /\.css$/,
exclude: /components/,
loader: 'style-loader!css-loader!postcss-loader'
},
{
test: /\.css$/,
include: /components/,
loader: 'style-loader!css-loader?modules&sourceMap&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss-loader'
},
{ test: /\.(png|jpg|gif|json)$/, loader: 'url-loader?limit=100000' },
{ test: /\.woff2?(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' }
]
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: path.join(cwd, 'frontend/index.html'),
favicon: path.join(cwd, 'frontend/assets/favicon.ico'),
inject: 'body'
}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
ERROR_BOARD_URL: JSON.stringify(process.env.ERROR_BOARD_URL),
APP_ENV: JSON.stringify('browser'),
MC_DEMO: JSON.stringify(process.env.MC_DEMO || false)
},
}),
new webpack.ContextReplacementPlugin(/node_modules\/moment\/locale/, /en/)
],
postcss: function(webpack) {
return [
require('postcss-import')({
addDependencyTo: webpack
}),
require('postcss-cssnext')
];
},
devServer: {
contentBase: path.join(cwd, 'dist'),
noInfo: true,
hot: true,
inline: true,
historyApiFallback: true,
proxy: {
'/api': {
target: 'http://localhost:3000'
},
'/socket.io': {
target: 'ws://localhost:3000',
ws: true
}
}
}
};
module.exports = config;