-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwebpack.config.babel.js
86 lines (82 loc) · 1.86 KB
/
webpack.config.babel.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
const path = require( 'path' );
const webpack = require( 'webpack' );
const merge = require( 'webpack-merge' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
module.exports = function( env ) {
const isDev = env === 'development';
let config = {
output: {
path: __dirname,
// The filename of the entry chunk as relative path inside the output.path directory.
filename: '[name].js'
},
devtool: isDev ? 'source-map' : 'hidden-source-map',
resolve: { extensions: [ '.js', '.css' ] },
module: {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
query: { presets: [[ 'es2015', { modules: false }]] },
exclude: path.resolve( __dirname, '/node_modules/' )
}, {
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|eot|ttf)$/,
loader: 'url-loader',
query: {
name: '[name].[ext]',
limit: 10000
}
}]
},
performance: {
assetFilter: assetFilename => {
return ! ( /\.map$/.test( assetFilename ) )
}
},
plugins: [
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify( env ) })
],
entry: {
'js/icon-picker': './js/src/icon-picker'
}
};
if ( isDev ) {
config = merge( config, {
module: {
rules: [{
test: /\.css$/,
use: [ 'style-loader', {
loader: 'css-loader',
options: { sourceMap: true }
}]
}]
},
devServer: {
port: 8080,
inline: true,
hot: false,
watchOptions: { poll: true }
},
performance: {
maxAssetSize: 1000000, // 1 mB.
maxEntrypointSize: 1000000
}
});
} else {
config = merge( config, {
module: {
rules: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract({ loader: 'css-loader?sourceMap' })
}]
},
plugins: [
new ExtractTextPlugin( '[name].css' ),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
})
]
});
}
return config;
};