-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
webpack.config.js.tmpl
35 lines (31 loc) · 1.24 KB
/
webpack.config.js.tmpl
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
module.exports = function () {
const v4 = new Error().stack.includes('webpack-cli@4.')
const infrastructureLogging = v4 ? {level: 'error'} : {
colors: false,
console: new console.Console(process.stderr, process.stderr),
level: 'error',
}
// We want webpack to spit out deterministic file hashes and module ids
// this will improve remote caching
// https://webpack.js.org/guides/caching/#module-identifiers
const optimization = {
moduleIds: v4 ? 'natural' : 'deterministic',
chunkIds: v4 ? 'natural' : 'deterministic',
}
// Webpack4: passing any 'output' overrides the standard output config in entries
const output = v4 ? {
path: __dirname,
} : {
// We want deterministic sourceMaps among other stuff that depends on the unique name.
// Default behavior of this field causes non-hermetic behavior. Eg; it looks into package.json
// which is always present in a non-sandboxed environment.
// See: https://webpack.js.org/configuration/output/#outputuniquename
// and https://webpack.js.org/configuration/output/#outputdevtoolmodulefilenametemplate
uniqueName: process.env.BAZEL_WORKSPACE,
}
return {
infrastructureLogging,
optimization,
output,{{ENTRIES}}{{DEVTOOL}}{{MODE}}
}
}