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