This repository has been archived by the owner on Feb 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
106 lines (96 loc) · 3.57 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
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var extractTranslationKeysRegexPlugin = require('webpack-extract-translation-keys-regex-plugin');
module.exports = {
entry: './index.js',
output: {
path: path.resolve(__dirname, ''),
filename: 'dist/js/react-dom-inspector.min.js'},
module: {
loaders: [
{
test: /\.less$/,
loader: ExtractTextPlugin.extract(['css-loader', 'less-loader'])
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract(['css-loader'])
},
{
test: /\.(png|jpg|woff|woff2|eot|ttf|otf)$/,
loaders: ['file-loader']
},
{
test: /\.(svg)$/,
loaders: ['svg-url-loader']
},
{
test: /.js?$/,
loader: 'babel-loader',
exclude: [
path.resolve(__dirname, 'node_modules')
],
query: {
plugins: [
'transform-runtime',
'transform-class-properties',
'transform-es3-member-expression-literals',
'transform-es3-property-literals',
'syntax-class-properties'
],
presets: ['es2015', 'react']
}
}
]
},
watchOptions: {
ignored: [
path.resolve(__dirname, 'docs/assets'),
path.resolve(__dirname, 'docs/assets/*/*'),
path.resolve(__dirname, 'docs/assets/js/react-dom-inspector.min.js'),
path.resolve(__dirname, 'docs/assets/css/style.min.css'),
path.resolve(__dirname, 'node_modules')
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new ExtractTextPlugin({
filename: 'dist/css/style.min.css',
allChunks: true
}),
new OptimizeCssAssetsPlugin({
assetNameRegExp: /\.min\.css$/g,
cssProcessor: require('cssnano'),
cssProcessorOptions: {discardComments: {removeAll: true}, zindex: false},
canPrint: true
}),
new webpack.optimize.AggressiveMergingPlugin(),
new extractTranslationKeysRegexPlugin({
functionReplace: 'polyglot.t($2$4$1$3$2$4',
functionPattern: /polyglot\.t\(\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)(")|'([^'\\]*(?:\\.[^'\\]*)*)('))/gm,
output: path.join(__dirname, 'dist', 'translations', 'english.json')
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true
},
comments: false,
sourceMap: false
}),
new webpack.optimize.AggressiveMergingPlugin(),
new CopyWebpackPlugin([
{from: 'dist/js/react-dom-inspector.min.js', to: 'docs/assets/js/react-dom-inspector.min.js'},
{from: 'dist/js/react-dom-inspector.min.js.map', to: 'docs/assets/js/react-dom-inspector.min.js.map'},
{from: 'dist/css/style.min.css', to: 'docs/assets/css/style.min.css'}
])
],
devtool: 'cheap-module-source-map'
};