42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const path = require('path');
|
|
const rules = require('./webpack.rules.js');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const CpWebpackPlugin = require('cp-webpack-plugin');
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
const zxingReaderWasm = require.resolve('zxing-wasm/reader/zxing_reader.wasm');
|
|
|
|
const output = path.resolve('./dist');
|
|
|
|
const entry = {
|
|
'index': path.resolve('./src/index.js'),
|
|
}
|
|
|
|
const config = {
|
|
entry: entry,
|
|
output: {
|
|
path: output,
|
|
filename: '[name].js',
|
|
globalObject: 'this',
|
|
libraryTarget: 'var',
|
|
},
|
|
module: {
|
|
rules,
|
|
},
|
|
plugins: [
|
|
new CleanWebpackPlugin(),
|
|
new HtmlWebpackPlugin({
|
|
filename: 'index.html',
|
|
template: 'demo.html'
|
|
}),
|
|
new CpWebpackPlugin([
|
|
{ from: path.resolve('./types'), to: path.resolve('./dist') },
|
|
{ from: path.resolve('./README.md'), to: path.resolve('./dist/README.md') },
|
|
{ from: zxingReaderWasm, to: path.resolve('./dist/lib/reader.wasm') },
|
|
])
|
|
],
|
|
devtool: 'cheap-module-souce-map',
|
|
mode: 'development',
|
|
};
|
|
|
|
module.exports = config;
|