forked from overleaf/web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
59 lines (52 loc) · 1.62 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
const path = require('path')
module.exports = {
// Defines the "entry point(s)" for the application - i.e. the file which
// bootstraps the application
entry: {
richText: './public/es/rich-text.js'
},
// Define where and how the bundle will be output to disk
// Note: webpack-dev-server does not write the bundle to disk, instead it is
// kept in memory for speed
output: {
path: path.join(__dirname, '/public/js/es'),
filename: '[name].js',
// Output as UMD bundle (allows main JS to import with CJS, AMD or global
// style code bundles
libraryTarget: 'umd',
// Name the exported variable from output bundle
library: ['Frontend', '[name]']
},
// TODO??
// Defines the external modules which will be stripped out when bundling for
// the main app. These modules are already loaded in the main app environment,
// so we strip them out to prevent conflicts.
// externals: {},
// Define how file types are handled by webpack
module: {
rules: [{
// Ensure eslint is run before compilation with babel
enforce: 'pre',
test: /\.js$/,
// Only compile application files (dependencies are in ES5 already)
exclude: /node_modules/,
loader: 'eslint-loader'
}, {
// Pass application JS files through babel-loader, compiling to ES5
test: /\.js$/,
// Only compile application files (dependencies are in ES5 already)
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
presets: ['env'],
// Configure babel-loader to cache compiled output so that subsequent
// compile runs are much faster
cacheDirectory: true
}
}]
}]
},
// TODO
// plugins: {}
}