-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.extension.js
executable file
·105 lines (94 loc) · 3.06 KB
/
webpack.config.extension.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
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV || 'development';
const DEST_DIR = process.env.DEST_DIR || 'build';
const config = {
module: {
rules: [
{
// Only run `.js` and `.jsx` files through Babel
test: /\.jsx?$/,
// Skip any files outside of your project's `src` directory
include: [
path.resolve(__dirname, 'src'),
],
// Skip any files in public path
exclude: [
path.resolve(__dirname, 'src', 'public'),
],
sideEffects: false,
loader: 'babel-loader',
options: JSON.parse(`${fs.readFileSync(path.resolve('.babelrc.web'))}`),
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.scss$/i,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
{
test: /\.woff2$/i,
use: ['file-loader'],
},
],
},
resolve: {
alias: {
lodash: path.resolve(__dirname, 'node_modules/lodash'),
'popper.js': path.resolve(__dirname, 'node_modules/popper.js'),
},
modules: [
'node_modules',
],
extensions: ['.js', '.jsx'],
},
//entry: {
// webapp: './src/webapp/webapp.js',
//},
devtool: (NODE_ENV === 'production' ? false : 'cheap-module-source-map'),
mode: (NODE_ENV === 'production' ? 'production' : 'development'),
target: 'electron-renderer',
devServer: {
historyApiFallback: {
disableDotRule: true,
},
},
output: {
path: path.resolve(__dirname, DEST_DIR),
filename: `[name].js`,
chunkFilename: `[name].chunk.[chunkhash].js`,
publicPath: '',
},
externals: [],
plugins: [
new webpack.DefinePlugin({
'process.env': {
HYPERKEYS_DEV_ENV: process.env.HYPERKEYS_DEV_ENV,
BROWSER: true,
HYPERKEYS_API_DOMAIN: process.env.HYPERKEYS_API_DOMAIN ? `"${process.env.HYPERKEYS_API_DOMAIN}"` : undefined,
HYPERKEYS_ENABLE_MOCKS: process.env.HYPERKEYS_ENABLE_MOCKS,
NODE_ENV: `"${NODE_ENV}"`,
},
//FIXME this disables entirely the React Devtool, cannot stay like this
//'__REACT_DEVTOOLS_GLOBAL_HOOK__': '({ isDisabled: true })'
}),
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/,
}),
],
watchOptions: {
aggregateTimeout: 1000,
},
};
if (NODE_ENV === 'production') {
config.optimization = config.optimization || {};
config.optimization.minimize = true;
config.optimization.usedExports = true;
}
module.exports = [
config,
];