-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
103 lines (98 loc) · 2.73 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
97
98
99
100
101
102
103
var path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const fPackage = require('./package.json');
const webpack = require('webpack');
const description = `'${fPackage.name}, v${fPackage.version} - ${fPackage.description}, by ${fPackage.author}. Renders [application/vnd.francy+json] MIME Type on Jupyter Environments.'`;
const defaultPlugins = [
new webpack.DefinePlugin({ VERSION: JSON.stringify(fPackage.version), FRANCY_DESC: description }),
new webpack.BannerPlugin(description)
];
/* global __dirname */
/* eslint-disable no-console */
module.exports = (env = {}) => {
console.log(`Running webpack for production environment? ${env.production}`);
/**
* Custom webpack loaders are generally the same for all webpack bundles, hence
* stored in a separate local variable.
*/
var loaders = [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [
['@babel/plugin-proposal-decorators', { 'legacy': true }],
['@babel/plugin-transform-classes', { 'globals': ['Error'] }]
]
}
}
}, {
test: /\.css$/,
use: ['style-loader', 'css-loader']
}];
var base = {
mode: env.production ? 'production' : 'development',
stats: {
colors: false,
hash: true,
timings: true,
assets: true,
chunks: true,
chunkModules: true,
modules: true,
children: true,
},
output: {
libraryTarget: 'amd',
},
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
uglifyOptions: {
ecma: 6,
compress: false
}
})
]
},
devtool: env.production ? '' : 'source-map',
module: {
rules: loaders
},
plugins: defaultPlugins,
node: {
fs: 'empty'
}
};
return [
/**
* Notebook extension
*
* This bundle only contains the part of the JavaScript that is run on
* load of the notebook. This section generally only performs
* some configuration for requirejs, and provides the legacy
* "load_ipython_extension" function which is required for any notebook
* extension.
*/
Object.assign({}, base, {
entry: [path.join(__dirname, 'index.js')],
output: Object.assign({}, base.output, {
filename: 'index.js',
path: path.join(__dirname, 'dist')
})
}),
Object.assign({}, base, {
entry: {
Vendors: 'antlr4/index.js'
},
output: Object.assign({}, base.output, {
filename: '[name].js',
path: path.join(__dirname, 'dist')
})
})
];
};
/* eslint-enable no-console */