-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
41 lines (41 loc) · 1.09 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
module.exports = function webpackConfig(config) {
//console.log('webpack config resolve', config.resolve);
//console.log('webpack config rules', config.module.rules);
const path = require('path');
const dev = config.mode === 'development';
const libDir = path.join(__dirname, 'libs/wasm');
const includePath = ['-I', libDir, '-I', path.join(libDir, 'kissfft')];
config.resolve.extensions.push('.c', '.cpp');
config.module.rules.push({
test: /\.c(?:pp)?$/,
use: [
{
loader: 'cpp-wasm-loader',
options: {
emccPath: 'emcc',
emccFlags: [
'-O2',
...includePath,
'-s',
"EXTRA_EXPORTED_RUNTIME_METHODS=['ccall','cwrap']",
'-s',
'WASM=1',
],
memoryClass: true,
fetchFiles: false,
asmJs: false,
wasm: true,
fullEnv: false,
},
},
{
loader: 'cpp-dependency-loader',
options: {
emccPath: 'emcc',
emccFlags: includePath,
},
},
],
});
return config;
};