forked from jvilk/BrowserFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
67 lines (65 loc) · 2 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
65
66
67
'use strict';
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const release = process.argv.indexOf('-p') !== -1;
const outDir = path.join(__dirname, '..', 'build', 'temp', 'library', '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)) {
try {
fs.mkdirSync(dir);
} catch (e) {
// Race condition: A parallel invocation of webpack
// may have already created directory. Check.
if (!fs.existsSync(dir)) {
throw e;
}
}
}
}
fs.writeFileSync(path.join(outDir, 'BFSBuffer.js'), 'module.exports = require(\'buffer\').Buffer;\n');
module.exports = {
devtool: 'source-map',
entry: path.join(__dirname, '..', 'build', 'temp', 'library', 'rollup', 'browserfs.rollup.js'),
output: {
path: __dirname,
filename: '..' + path.sep + 'build' + path.sep + 'browserfs.' + (release ? 'min.js' : 'js'),
libraryTarget: 'umd',
library: 'BrowserFS',
// Work around https://github.com/webpack/webpack/issues/6642 until
// https://github.com/webpack/webpack/issues/6525 lands.
globalObject: 'this',
},
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/library/webpack/BFSBuffer.js')
}
},
plugins: [
new webpack.ProvidePlugin({ process: 'process', Buffer: 'BFSBuffer' })
],
node: {
process: false,
Buffer: false,
setImmediate: false
},
target: 'web',
module: {
rules: [
// Load source maps for any relevant files.
{
test: /(\.js$|\.ts$)/,
enforce: 'pre',
loader: 'source-map-loader'
}
]
}
};