-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
51 lines (46 loc) · 1.28 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
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const { DefinePlugin } = require('webpack')
const config = require('./config')
const EsmWebpackPlugin = require('@purtuga/esm-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const contentBase = path.resolve(process.cwd())
module.exports = {
devtool: 'cheap-module-source-map',
devServer: {
contentBase,
contentBasePublicPath: '/'
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
imgUrl: config.imgUrl,
wasmPath: config.wasmPath,
title: 'XObjectDetector',
template: 'index.html'
}),
new DefinePlugin({
'IMG_URL': JSON.stringify(config.imgUrl),
'WASM_PATH': JSON.stringify(config.wasmPath),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
],
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/
}
]
},
output: {
filename: 'XObjectDetector.js',
path: path.resolve(contentBase, 'dist')
}
}
if (process.env.NODE_ENV === 'production') {
module.exports.plugins.push(new EsmWebpackPlugin())
module.exports.output.library = 'X_OBJECT_DETECTOR'
module.exports.output.libraryTarget = 'var'
}