-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
169 lines (163 loc) · 4.13 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HappyPack = require('happypack');
const webpack = require('webpack');
const isProd = process.env.NODE_ENV === 'production';
module.exports = {
devtool: isProd
? '#source-map'
: '#eval',
context: path.join(__dirname, 'src'),
entry: {
dist: ['babel-polyfill', './index.js']
},
output: {
path: path.join(__dirname, 'dist'),
publicPath: 'dist/',
filename: '../dist.js'
},
module: {
rules: [
{
test: /\.js$/,
include: /node_modules\/(@parity\/dapp-|ethereumjs-util)/,
use: [ {
loader: 'happypack/loader',
options: {
id: 'babel'
}
} ]
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [ {
loader: 'happypack/loader',
options: {
id: 'babel'
}
} ]
},
{
test: /\.json$/,
use: ['json-loader']
},
{
test: /\.ejs$/,
use: ['ejs-loader']
},
{
test: /\.css$/,
include: /semantic-ui-css/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
minimize: isProd
}
}
]
})
},
{
test: /\.css$/,
exclude: /semantic-ui-css/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
importLoaders: 1,
localIdentName: '[name]_[local]_[hash:base64:10]',
minimize: isProd,
modules: true
}
},
{
loader: 'postcss-loader',
options: {
plugins: (loader) => [
require('postcss-import'),
require('postcss-nested'),
require('postcss-simple-vars')
]
}
}
]
})
},
{
test: /\.(png|jpg|svg|woff|woff2|ttf|eot|otf)(\?.*)?$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[hash:10].[ext]',
outputPath: '',
useRelativePath: false
}
}
}
],
noParse: [
/node_modules\/sinon/
]
},
resolve: {
alias: {},
modules: [
path.join(__dirname, 'node_modules')
],
extensions: ['.json', '.js', '.jsx'],
unsafeCache: true
},
node: {
fs: 'empty'
},
plugins: [
new ExtractTextPlugin({
filename: '../dist.css'
}),
new HappyPack({
id: 'babel',
threads: 4,
loaders: ['babel-loader']
}),
new HtmlWebpackPlugin({
filename: '../index.html',
template: './index.ejs',
chunks: ['dist']
}),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
}),
isProd && new webpack.optimize.ModuleConcatenationPlugin(),
isProd && new webpack.optimize.UglifyJsPlugin({
screwIe8: true,
sourceMap: true,
compress: {
warnings: false
},
output: {
comments: false
}
})
].filter((plugin) => plugin)
};