-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
50 lines (47 loc) · 1.41 KB
/
Copy pathwebpack.config.js
File metadata and controls
50 lines (47 loc) · 1.41 KB
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
const path = require('path')
const CopyPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin')
const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin')
const webpack = require('webpack')
const wasm_package_name = 'viewer_crypto'
module.exports = {
entry: './src/client/index.js',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'index_bundle.js'
},
plugins: [
new webpack.DefinePlugin({
wasm_package_name: JSON.stringify(wasm_package_name),
svf_path: JSON.stringify(process.env.svf_path)
}),
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, 'src/client/sw.js')
}),
new CopyPlugin([
{
from: 'src/public/',
to: ''
},
{
from: `src/wasm/pkg/${wasm_package_name}_bg.wasm`,
to: './'
},
{
from: `src/wasm/pkg/${wasm_package_name}.js`,
to: './',
transform (content, path) {
return content.toString().replace(`import * as wasm from './${wasm_package_name}_bg.wasm';`, '').replace(/export function/g, 'function')
} }
]),
new HtmlWebpackPlugin({
title: ''
}),
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, 'src/wasm'),
extraArgs: '--no-typescript',
outName: wasm_package_name
})
]
}