This repository has been archived by the owner on Sep 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 375
/
webpack.config.js
96 lines (89 loc) · 2.6 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
/* eslint-disable */
const webpack = require('webpack');
const path = require('path');
const Extract = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MinifyPlugin = require("babel-minify-webpack-plugin");
const PROD = process.env.NODE_ENV === 'production';
const DEV = !PROD;
const config = {
entry: ['./examples/index.js'],
output: {
filename: DEV ? 'bundle.js' : 'bundle.[hash].js',
path: path.resolve(__dirname, '../public'),
publicPath: DEV ? '/' : '/react-contextmenu/',
hashDigestLength: 6,
sourceMapFilename: 'bundle.js.map'
},
resolve: {
modules: [
path.resolve(__dirname, '../'),
'node_modules'
]
},
module: {
rules: [
{
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
presets: [
'react',
['env', {
modules: false,
targets: {
browsers: 'IE >= 11, Edge >= 12, FireFox >= 38, Chrome >= 47, Opera >= 34, Safari >= 8'
}
}]
],
plugins: [
'transform-class-properties'
]
}
}],
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname)
]
},
{
test: /\.css$/,
use: Extract.extract({
fallback: 'style-loader',
use: [{
loader: 'css-loader'
}]
}),
}
]
},
plugins: [
new Extract({
filename: DEV ? 'styles.css' : 'styles.[contenthash:6].css',
allChunks: true
}),
new HtmlWebpackPlugin({
template: 'examples/index.html',
inject: true,
filename: 'index.html'
})
]
};
!PROD && (config.devtool = 'source-map');
PROD && config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false,
}
})
);
PROD && config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new MinifyPlugin()
);
module.exports = config;