onnxruntime/js/common/webpack.config.js
Yulong Wang 4ebc9c3b5e
[JS] onnxruntime-web (#7394)
* add web

* add script and test

* fix lint

* add test/data/ops

* add test/data/node/ to gitignore

* modify scripts

* add onnxjs

* fix tests

* fix test-runner

* fix sourcemap

* fix onnxjs profiling

* update test list

* update README

* resolve comments

* set wasm as default backend

* rename package

* update copyright header

* do not use class "Buffer" in browser context

* revise readme
2021-04-27 00:04:25 -07:00

49 lines
1.3 KiB
JavaScript

const path = require('path');
const webpack = require('webpack');
function buildConfig({
suffix = '',
format = 'umd',
target = 'ES2017',
mode = 'production',
devtool = 'source-map'
}) {
return {
entry: path.resolve(__dirname, 'lib/index.ts'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: `ort-common${suffix}.js`,
library: {
name: format === 'commonjs' ? undefined : 'ort',
type: format
}
},
resolve: { extensions: ['.ts', '.js'] },
plugins: [new webpack.WatchIgnorePlugin({ paths: [/\.js$/, /\.d\.ts$/] })],
module: {
rules: [{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
compilerOptions: { target: target }
}
}
]
}]
},
mode: mode,
devtool: devtool,
};
}
module.exports = (env, argv) => {
return [
buildConfig({ suffix: '.es6', mode: 'development', devtool: 'inline-source-map', target: 'es6' }),
buildConfig({ mode: 'development', devtool: 'inline-source-map', target: 'es5' }),
buildConfig({ suffix: '.es6.min', target: 'es6' }),
buildConfig({ suffix: '.min', target: 'es5' }),
buildConfig({ format: 'commonjs', suffix: '.node', target: 'es5' }),
];
};