forked from vkbansal/react-contextmenu
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
73 lines (68 loc) · 2.04 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
/* eslint-disable */
const webpack = require('webpack');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const PROD = process.env.NODE_ENV === 'production';
const DEV = !PROD;
const config = {
mode: PROD ? "production" : "development",
entry: ['./examples/index.js'],
output: {
filename: 'bundle.[contenthash].js',
path: path.resolve(__dirname, '../public'),
publicPath: DEV ? '/' : '/react-contextmenu/',
hashDigestLength: 6,
},
resolve: {
modules: [
path.resolve(__dirname, '../'),
'node_modules'
]
},
module: {
rules: [
{
test: /\.js$/,
use: [{
loader: 'babel-loader',
options: {
assumptions: {
setPublicClassFields: true
},
presets: [
'@babel/preset-react',
['@babel/preset-env', {
modules: false,
targets: "defaults",
}]
],
}
}],
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname)
]
},
{
test: /\.css$/,
use: [
DEV ? "style-loader": MiniCssExtractPlugin.loader,
"css-loader"
],
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: DEV ? 'styles.css' : 'styles.[contenthash:6].css',
}),
new HtmlWebpackPlugin({
template: 'examples/index.html',
inject: true,
filename: 'index.html'
})
]
};
!PROD && (config.devtool = 'source-map');
module.exports = config;