forked from microsoft/onnxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
40 lines (34 loc) · 1.36 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
const util = require('util');
const path = require('path');
const webpack = require('webpack');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
module.exports = (env, argv) => {
const bundleMode = argv['bundle-mode'] || 'prod'; // 'prod'|'dev'|'perf'|undefined;
const config = {
resolve: {extensions: ['.ts', '.js']},
plugins: [new webpack.WatchIgnorePlugin([/\.js$/, /\.d\.ts$/])],
module: {rules: [{test: /\.tsx?$/, loader: 'ts-loader'}]},
node: {fs: 'empty'}
};
if (bundleMode === 'perf' || bundleMode === 'dev') {
config.entry = path.resolve(__dirname, 'test/test-main.ts');
} else {
config.entry = path.resolve(__dirname, 'lib/api/index.ts');
}
if (bundleMode === 'perf') {
config.output = {path: path.resolve(__dirname, 'test'), filename: 'onnx.perf.js', libraryTarget: 'umd'};
} else if (bundleMode === 'dev') {
config.output = {path: path.resolve(__dirname, 'test'), filename: 'onnx.dev.js', libraryTarget: 'umd'};
} else {
config.output = {path: path.resolve(__dirname, 'dist'), filename: 'onnx.min.js', libraryTarget: 'umd'};
}
if (argv.mode === 'production') {
config.mode = 'production';
config.devtool = 'source-map';
} else {
config.mode = 'development';
config.devtool = 'inline-source-map';
config.plugins.push(new HardSourceWebpackPlugin());
}
return config;
};