-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathwebpack.config.js
More file actions
136 lines (134 loc) · 3.89 KB
/
Copy pathwebpack.config.js
File metadata and controls
136 lines (134 loc) · 3.89 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const confPaths = JSON.parse(fs.readFileSync('webpack-conf-paths.json').toString())
module.exports = env => ({
mode: 'production',
target: ['web', 'es6'],
entry: {
auth: [
'js/djaodjin-postal.js',
'js/djaodjin-password-strength.js'
],
base: [
'js/djresources.js',
'js/djaodjin-menubar.js',
'js/djaodjin-dashboard.js',
'js/djaoapp-theme-color-mode.js',
'js/djaodjin-privacy.js',
],
'djaodjin-vue': [
'js/djaodjin-upload.js',
'js/djaodjin-signup-vue.js',
'js/djaodjin-saas-vue.js',
'js/djaodjin-rules-vue.js',
'js/djaodjin-themes-vue.js',
'js/djaodjin-metrics.js',
'js/djaodjin-djaoapp-vue.js',
],
pages: [
'js/djaodjin-upload.js',
'js/djaodjin-editor.js',
'js/djaodjin-sidebar-gallery.js',
'js/djaodjin-plan-edition.js',
],
saas: [
'js/djaodjin-postal.js',
'js/djaodjin-saas.js',
'js/djaodjin-stripe.js'
],
'theme-editors': [
'js/djaodjin-panel-buttons.js',
'js/djaodjin-code-editor.js',
'js/djaodjin-style-editor.js',
],
},
module: {
rules:[{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {
configPath: __dirname + "/package.json",
debug: true,
//useBuiltIns: 'usage',
// XXX If we starts to use the polyfill, there is a problem
// with Vue/extend in 'js/assess-vue.js'.
corejs: "3.22"
}]]
}
}
}, {
test: /djresources\.js$/,
loader: 'expose-loader',
type: "javascript/auto",
options: {
exposes: [{
globalName: 'clearMessages',
moduleLocalName: 'clearMessages',
}, {
globalName: 'showMessages',
moduleLocalName: 'showMessages',
}, {
globalName: 'showErrorMessages',
moduleLocalName: 'showErrorMessages',
}, {
globalName: 'getUrlParameter',
moduleLocalName: 'getUrlParameter',
}, {
globalName: 'djApi',
moduleLocalName: 'djApi',
}]
}
}
]
},
output: {
path: path.resolve(__dirname, 'htdocs/assets/cache'),
filename: env.app_version_suffix ? '[name]' + env.app_version_suffix + '.js' : '[name].js',
},
externals: {
jQuery: 'jQuery',
Vue: 'Vue'
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: {
reserved: ['clearMessages', 'showMessages', 'showErrorMessages', 'getUrlParameter', 'djApi', 'Vue'],
properties: false,
},
}
}),
],
},
plugins: [
new webpack.LoaderOptionsPlugin({
debug: true
}),
new webpack.ProvidePlugin({
httpRequestMixin: [
'js/djresourcesvue.js', 'httpRequestMixin'],
itemMixin: ['js/djresourcesvue.js', 'itemMixin'],
itemListMixin: ['js/djresourcesvue.js', 'itemListMixin'],
paramsMixin: ['js/djresourcesvue.js', 'paramsMixin'], // used in djaodjin-saas-vue.js
typeAheadMixin: ['js/djresourcesvue.js', 'typeAheadMixin'],
updateChart: ['js/djaodjin-metrics.js', 'updateChart'],
updateBarChart: ['js/djaodjin-metrics.js', 'updateBarChart'],
})
],
resolve: {
fallback: {
"fs": require.resolve("fs"),
},
modules: confPaths.node_modules,
},
resolveLoader: {
modules: confPaths.node_modules,
}
});