forked from internetarchive/openlibrary
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
84 lines (74 loc) · 2.57 KB
/
webpack.config.js
File metadata and controls
84 lines (74 loc) · 2.57 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* eslint-env node, es6 */
const
path = require('path'),
prod = process.env.NODE_ENV === 'production',
// The output directory for all build artifacts. Only absolute paths are accepted by
// output.path.
distDir = path.resolve(__dirname, 'static/build');
module.exports = {
// Apply the rule of silence: https://wikipedia.org/wiki/Unix_philosophy.
stats: {
all: false,
// Output a timestamp when a build completes. Useful when watching files.
builtAt: true,
errors: true,
warnings: true
},
// Fail on the first build error instead of tolerating it for prod builds. This seems to
// correspond to optimization.noEmitOnErrors.
bail: prod,
// Specify that all paths are relative the Webpack configuration directory not the current
// working directory.
context: __dirname,
// A map of ResourceLoader module / entry chunk names to JavaScript files to pack.
entry: {
'all': './openlibrary/plugins/openlibrary/js/index.js'
},
externals: [ 'jquery' ],
resolve: {
alias: {}
},
module: {
rules: [ {
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
// Beware of https://github.com/babel/babel-loader/issues/690.
// Changes to browsers require manual invalidation.
cacheDirectory: true
}
}
}, {
test: /\.less$/,
loader: [
'style-loader',
'css-loader',
'less-loader' // compiles Less to CSS
]
} ]
},
optimization: {
// Don't produce production output when a build error occurs.
noEmitOnErrors: prod
},
output: {
// Specify the destination of all build products.
path: distDir,
// Store outputs per module in files named after the modules. For the JavaScript entry
// itself, append .js to each ResourceLoader module entry name.
filename: '[name].js',
// Expose the module.exports of each module entry chunk through the global
// ol (open library)
library: [ 'ol' ],
libraryTarget: 'this'
},
// Accurate source maps at the expense of build time.
// The source map is intentionally exposed
// to users via sourceMapFilename for prod debugging.
devtool: 'source-map',
performance: {
// Size violations for prod builds fail; development builds are unchecked.
hints: prod ? 'error' : false
}
};