This repository has been archived by the owner on May 31, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 424
/
webpack.config.js
96 lines (87 loc) · 2.43 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
var path = require('path');
var merge = require('webpack-merge');
var webpack = require('webpack');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
var cachingDisabled = process.env.DISABLE_WEBPACK_CACHE !== undefined;
var javascriptLoaders = [{ loader: 'cache-loader' }, { loader: 'babel-loader' }];
if (cachingDisabled) {
console.log('Caching is disabled.');
javascriptLoaders.shift()
} else {
console.log('Caching is enabled.')
}
var commonConfig = merge([
{
entry: {
'batavia': './batavia/batavia.js'
},
output: {
path: path.join(__dirname, './dist'),
filename: '[name].js',
library: 'batavia',
libraryTarget: 'umd',
globalObject: "typeof self !== 'undefined' ? self : this" // Workaround for webpack issue #6526
},
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
target: 'web',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
],
resolve: {symlinks: false},
module: {
rules: [
{
test: /\.js$/,
use: javascriptLoaders,
exclude: '/node_modules/'
}
]
}
}
]);
var productionConfig = merge([
{
output: {
sourceMapFilename: '[name].js.map'
},
devtool: 'eval-source-map'
}
]);
var developmentConfig = merge([
{
entry: {
'codemirror': [
'./node_modules/codemirror/lib/codemirror.js',
'./node_modules/codemirror/lib/codemirror.css',
'./node_modules/codemirror/mode/python/python.js'
]
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
})
],
module: {
rules: [
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
'css-loader'
]
}
]
}
}
]);
module.exports = function(env, argv) {
var config =
argv.mode === "production" ? productionConfig : developmentConfig;
return merge([commonConfig, config]);
};