forked from jvilk/BrowserFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
64 lines (62 loc) · 1.93 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const outDir = path.join(__dirname, '..', 'build', 'temp', 'tests', 'webpack');
const outDirComponents = outDir.split(path.sep);
// i = 1: Skip '..' component.
for (let i = 1; i < outDirComponents.length; i++) {
const dir = outDirComponents.slice(0, i + 1).join(path.sep);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
}
fs.writeFileSync(path.join(outDir, 'BFSBuffer.js'), 'module.exports = require(\'buffer\').Buffer;\n');
module.exports = {
devtool: 'source-map',
entry: {
'./harness/test': require.resolve('../build/temp/tests/rollup/test.rollup.js'),
'./harness/factories/workerfs_worker': require.resolve('../build/temp/tests/rollup/test_worker.rollup.js')
},
output: {
path: __dirname,
filename: '[name].js'
},
resolve: {
extensions: ['.js', '.json'],
// Use our versions of Node modules.
alias: {
'buffer': path.posix.resolve(__dirname, '..', 'node_modules', 'buffer', 'index.js'),
'path': require.resolve('bfs-path'),
'process': require.resolve('bfs-process'),
'BFSBuffer': require.resolve('../build/temp/tests/webpack/BFSBuffer.js')
}
},
plugins: [
new webpack.IgnorePlugin(/^fs$/),
new webpack.ProvidePlugin({ process: 'process', Buffer: 'BFSBuffer' }),
new webpack.NormalModuleReplacementPlugin(/tests\/emscripten/, function(requireReq) {
// Ignore source-map-loader requests.
const req = requireReq.request;
if (req.indexOf('!') === -1) {
requireReq.request = path.resolve(__dirname, 'tests', 'emscripten', path.basename(req));
}
})
],
node: {
process: false,
Buffer: false,
setImmediate: false
},
target: 'web',
module: {
rules: [
// Load source maps for any relevant files.
{
test: /\.js$/,
enforce: 'pre',
loader: 'source-map-loader'
}
]
}
};