-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
61 lines (58 loc) · 1.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
const path = require('path');
const webpack = require('webpack');
const isProduction = process.env.NODE_ENV == 'production';
const filePath = process.env.FILE_PATH || 'src/index.js';
console.log(`target file: ${filePath}`);
const config = {
entry: path.resolve(__dirname, filePath), //file which you want to build
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new webpack.EnvironmentPlugin({
SERIAL: "",
AES_KEY: "",
TEST: false,
API_SERVER: "miniegg-plus-backend-dev.ainize.ai",
npm_package_version: process.env.npm_package_version
}),
],
externals: {
'events': 'commonjs events',
'gpio': 'commonjs gpio',
'led': 'commonjs led',
'button': 'commonjs button',
'pwm': 'commonjs pwm',
'adc': 'commonjs adc',
'i2c': 'commonjs i2c',
'spi': 'commonjs spi',
'uart': 'commonjs uart',
'rp2': 'commonjs rp2',
'rtc': 'commonjs rtc',
'graphics': 'commonjs graphics',
'at': 'commonjs at',
'stream': 'commonjs stream',
'net': 'commonjs net',
'dgram': 'commonjs dgram',
'http': 'commonjs http',
'wifi': 'commonjs wifi',
'url': 'commonjs url',
'fs': 'commonjs fs',
'vfs_lfs': 'commonjs vfs_lfs',
'flash': 'commonjs flash'
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.json'],
modules: [path.resolve(__dirname, "src/modules"), "node_modules"],
},
};
module.exports = () => {
if (isProduction) {
config.mode = 'production';
} else {
config.mode = 'development';
}
return config;
};