-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
108 lines (105 loc) · 2.83 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
103
104
105
106
107
108
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FaviconsWebpackPlugin = require('favicons-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const config = {
devtool: 'eval',
entry: [
path.join(path.join(__dirname, 'src', 'client'), 'Index.jsx')
],
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js',
publicPath: '/'
},
resolve: {
extensions: ['', '.jsx', '.js', '.css'],
modulesDirectories: ['node_modules', 'resources'],
alias: {}
},
plugins: [
new FaviconsWebpackPlugin({
logo: path.join(__dirname, 'src', 'client', 'res', 'logo.png'),
prefix: 'icons-[hash]/',
background: '#00bcd4',
emitStats: false,
persistentCache: false
}),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'client', 'index.tpl.html'),
inject: 'body',
filename: 'index.html'
}),
new ExtractTextPlugin('[name].css', { allChunks: true }),
new CopyWebpackPlugin([{
from: 'node_modules/monaco-editor/min/vs',
to: 'vs',
}])
],
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel'],
include: path.join(__dirname, 'src', 'client')
},
{
test: /\.css$/,
exclude: /\.import\.css$/,
loader: 'style!css',
include: path.resolve(__dirname, 'src', 'client')
},
{
test: /\.import\.css$/,
loader: 'style!css',
include: path.resolve(__dirname, 'src', 'client')
},
{
test: /\.(jpg|png|jpg|png|woff|eot|ttf|svg|gif)$/,
loader: 'file'
},
{
test: /manifest.json$/,
loader: 'file-loader?name=manifest.json!web-app-manifest-loader'
}
]
},
eslint: {
configFile: path.join(__dirname, '.eslintrc'),
failOnWarning: false,
failOnError: false
}
}
if (process.env.NODE_ENV === 'production') {
delete config.devtool
config.plugins.push(new webpack.optimize.DedupePlugin())
config.plugins.push(new webpack.optimize.AggressiveMergingPlugin())
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
},
mangle: {
except: ['exports', 'require']
},
output: {
comments: false
}
}))
config.plugins.push(new webpack.DefinePlugin({
'process.env': { NODE_ENV: '"production"' }
}))
} else {
config.entry.push('webpack-hot-middleware/client')
config.plugins.push(new webpack.HotModuleReplacementPlugin())
}
module.exports = config