-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathwebpack.config.js
executable file
·91 lines (87 loc) · 2.63 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
const webpack = require('webpack'); //to access built-in plugins
const CompressionPlugin = require('compression-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const FileManagerPlugin = require('filemanager-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const path = require('path')
function OZTreeModule_src(x) {
return path.resolve(__dirname, 'OZprivate', 'rawJS', 'OZTreeModule', 'src', x);
}
function OZTreeModule_dist(x) {
if (x) {
return path.resolve(__dirname, 'OZprivate', 'rawJS', 'OZTreeModule', 'dist', x);
} else {
return path.resolve(__dirname, 'OZprivate', 'rawJS', 'OZTreeModule', 'dist');
}
}
var config = {
performance: {
// See https://github.com/OneZoom/OZtree/issues/246
maxEntrypointSize: 355000,
maxAssetSize: 355000
},
stats: {
children: false
},
entry: {
//at: './OZprivate/rawJS/OZTreeModule/src/at.js',
OZentry: OZTreeModule_src('OZentry.js'),
OZui: OZTreeModule_src('OZui.js'),
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
test: /\.js(\?.*)?$/i,
}),
],
},
output: {
filename: '[name].[contenthash].js',
path: OZTreeModule_dist(),
//publicPath affects the script address in OZ_script.html generated by html webpack plugin
publicPath: '/' + path.basename(__dirname) + '/static/OZTreeModule/dist/',
library: '[name]'
},
externals: {
'jquery': 'jQuery'
},
module: {
rules: [
{
test: /\.js/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
scriptLoading: 'blocking',
filename: 'OZentry.html',
chunks: ['OZentry'],
// This template contains the script tags refering to the js files generated by
// the webpack compile command
template: OZTreeModule_src('OZ_script_template.html')
}),
new HtmlWebpackPlugin({
scriptLoading: 'blocking',
filename: 'OZui.html',
chunks: ['OZui'],
// This template contains the script tags refering to the js files generated by
// the webpack compile command, but only for the UI components
template: OZTreeModule_src('OZ_script_template.html')
}),
new FileManagerPlugin({
events: { onEnd: {
copy: [
{source: OZTreeModule_dist("OZentry.[contenthash].js"), destination: OZTreeModule_dist("OZentry.js")},
{source: OZTreeModule_dist("OZui.[contenthash].js"), destination: OZTreeModule_dist("OZui.js")},
]
}
}}),
new CompressionPlugin(
)
]
}
module.exports = config;