-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
68 lines (59 loc) · 1.84 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
const path = require('path')
const webpack = require('webpack')
const standardOptions = require('./package.json').standard
const installJSON = require('./install.json')
const iconConfigs = installJSON.options.properties.icons.properties
const environment = process.env.NODE_ENV || 'development'
const $ = {}
const modulePattern = /(node_modules|bower_components)/
// TODO: This causes some issues when combined with app testing.
// $.devtool = environment === 'development' ? 'eval-source-map' : false
$.entry = {
app: path.resolve(__dirname, './source', 'app.js'),
'icons/bootstrapper': path.resolve(__dirname, './source', 'icons', 'bootstrapper.js'),
style: path.resolve(__dirname, './source', 'app.css')
}
Object.keys(iconConfigs).forEach(id => {
$.entry[`icons/${id}`] = path.resolve(__dirname, './source', 'icons', `${id}.js`)
})
$.output = {
filename: '[name].js',
sourceMapFilename: '[name].map',
path: path.resolve(__dirname, 'build')
}
$.plugins = []
if (environment === 'production') {
$.plugins.push(new webpack.LoaderOptionsPlugin({minimize: false, debug: false}))
}
$.module = {
rules: [
// Use the latest CSS with PostCSS.
{
test: /\.css$/,
loaders: 'file-loader?name=[name].[ext]!extract-loader!css-loader!postcss-loader'
},
// Use the latest JavaScript with Babel.
{ test: /\.js$/, exclude: modulePattern, loader: 'babel-loader' },
// Catch errors as you develop.
{
test: /\.js?$/,
enforce: 'pre',
exclude: modulePattern,
loader: 'standard-loader',
options: {
error: false,
snazzy: true,
parser: 'babel-eslint'
}
},
// Format the final compiled output.
{
test: /\.js$/,
enforce: 'post',
exclude: modulePattern,
loader: 'standard-format-loader',
options: standardOptions
}
]
}
module.exports = $