-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
46 lines (40 loc) · 1.51 KB
/
webpack.config.js
File metadata and controls
46 lines (40 loc) · 1.51 KB
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
const path = require('path');
const { webpack} = require('webpack');
module.exports = {
target: 'electron', // Ensure the output is compatible with web browsers
mode: 'production', // Set the mode to development for easier debugging
resolve: {
extensions: ['.mjs', '.js', '.jsx', '.json'],
/**
* 1. Polyfill only the Node-core modules your *frontend* really needs.
* 2. Explicitly stub out anything that must *not* run in the browser.
*/
fallback: {
path: require.resolve('path-browserify'),
os: require.resolve('os-browserify/browser'),
events: require.resolve('events/'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util/'),
process: require.resolve('process/browser'),
buffer: require.resolve('buffer/'),
/* ❌ These APIs do not exist in the browser.
Stubbing them as `false` prevents webpack from
leaving a naked `require("fs")` in the output. */
fs: false,
sqlite3: false,
usb: false,
events: false,
},
},
plugins: [
/**
* Make `process` and `Buffer` magically available to every module that
* expects the Node globals—just like webpack ≤ 4 used to do.
*/
new webpack.ProvidePlugin({
process: 'process/browser',
Buffer: ['buffer', 'Buffer'],
}),
new webpack.NormalModuleReplacementPlugin(/element-ui[\/\\]lib[\/\\]locale[\/\\]lang[\/\\]zh-CN/, 'element-ui/lib/locale/lang/en')
],
};