forked from lspgn/edge-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
47 lines (45 loc) · 1.41 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
const CopyPlugin = require('copy-webpack-plugin')
const path = require('path')
const spawn = require('child_process').spawnSync
module.exports = {
context: path.resolve(__dirname, '.'),
devtool: 'nosources-source-map',
entry: './index.js',
target: 'webworker',
plugins: [
{
apply: compiler => {
compiler.hooks.compilation.tap('emscripten-build', compilation => {
let result = spawn('node', ['build.js'], { stdio: 'inherit' })
if (result.status != 0) {
compilation.errors.push('emscripten build failed')
} else {
console.log('emscripten build complete')
}
})
},
},
new CopyPlugin([
// we need to manually copy this instead of requiring from
// our script source code, since wasm files are bound to global scope
// in Workers, rather than being fetched like the browser.
// wranglerjs also needs to see a wasm file in order for it to be sent to the api
// correctly.
{ from: './build/module.wasm', to: './worker/module.wasm' },
]),
],
optimization: {
minimize: false
},
module: {
rules: [
// Emscripten JS files define a global. With `exports-loader` we can
// load these files correctly (provided the global’s name is the same
// as the file name).
{
test: /emscripten\.js$/,
loader: 'exports-loader',
},
],
},
}