-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7ed683
commit fb1ef44
Showing
3 changed files
with
70 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const webpack = require('webpack'); | ||
|
||
module.exports = { | ||
webpack: { | ||
configure: (webpackConfig) => { | ||
const wasmExtensionRegExp = /\.wasm$/; | ||
webpackConfig.resolve.extensions.push('.wasm'); | ||
webpackConfig.experiments = { | ||
asyncWebAssembly: true, | ||
lazyCompilation: true, | ||
syncWebAssembly: true, | ||
topLevelAwait: true, | ||
}; | ||
webpackConfig.resolve.fallback = { | ||
...webpackConfig.resolve.fallback, | ||
fs: false, // fs is not typically available in the browser | ||
crypto: require.resolve('crypto-browserify'), | ||
stream: require.resolve('stream-browserify'), | ||
util: require.resolve('util'), | ||
os: require.resolve('os-browserify/browser'), | ||
path: require.resolve('path-browserify'), | ||
http: require.resolve('stream-http'), | ||
https: require.resolve('https-browserify'), | ||
net: false, // net is not typically available in the browser | ||
tls: false, // tls is not typically available in the browser | ||
dns: require.resolve('dns.js'), | ||
zlib: require.resolve('browserify-zlib'), | ||
url: require.resolve('url'), | ||
buffer: require.resolve('buffer/'), | ||
assert: require.resolve('assert/'), | ||
dgram: false, // dgram is not typically available in the browser | ||
process: require.resolve('process'), | ||
}; | ||
webpackConfig.module.rules.forEach((rule) => { | ||
(rule.oneOf || []).forEach((oneOf) => { | ||
if (oneOf.type === 'asset/resource') { | ||
oneOf.exclude.push(wasmExtensionRegExp); | ||
} | ||
}); | ||
}); | ||
webpackConfig.plugins.push( | ||
new webpack.ProvidePlugin({ | ||
process: 'process', | ||
Buffer: ['buffer', 'Buffer'], | ||
}), | ||
{ | ||
apply: (compiler) => { | ||
compiler.hooks.done.tap('DonePlugin', (stats) => { | ||
console.log('Compile is done !'); | ||
setTimeout(() => { | ||
process.exit(0); | ||
}); | ||
}); | ||
} | ||
} | ||
); | ||
|
||
return webpackConfig; | ||
}, | ||
}, | ||
jest: { | ||
configure: { | ||
globals: { | ||
CONFIG: true, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters