-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
106 lines (103 loc) · 3.46 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
104
105
106
/**
`chart.js` and `chartjs-plugin-annotation.js` do not have an ES5 distribution
by default. The annotation plugin though import chart.js and chart.js' helpers
in such a way that if we are not careful to install the whole chart.js module
in vendor/chart.js/ and update the modules path (resolveLoader.modules)
properly, we end-up with an ES6 code base in /static/cache/ (checked by
es-check in Makefile rule).
The annotation plugin also needs to be registered (done through
`chart-bundle.js`).
*/
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
var confPaths = JSON.parse(fs.readFileSync('webpack-conf-paths.json').toString())
module.exports = {
mode: 'production',
target: ['web', 'es5'],
entry: {
assess: [
'js/chart-bundle.js',
'js/djaodjin-survey-vue.js',
'js/djaodjin-pages-vue.js',
'js/assess-vue.js',
],
editors: [
'js/djaodjin-survey-vue.js',
'js/djaodjin-pages-vue.js',
'js/editors-vue.js',
],
reporting: [
'js/chart-bundle.js',
'js/djaodjin-survey-vue.js',
'js/reporting-vue.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"
}]]
}
}
}
]
},
output: {
path: path.resolve(__dirname, 'htdocs/static/cache'),
filename: '[name].js',
},
externals: {
jQuery: 'jQuery',
},
plugins: [
new webpack.LoaderOptionsPlugin({
debug: true
}),
new webpack.ProvidePlugin({
httpRequestMixin: [
'js/djaodjin-resources-vue.js', 'httpRequestMixin'],
itemMixin: ['js/djaodjin-resources-vue.js', 'itemMixin'],
itemListMixin: ['js/djaodjin-resources-vue.js', 'itemListMixin'],
paramsMixin: ['js/djaodjin-resources-vue.js', 'paramsMixin'],
typeAheadMixin: ['js/djaodjin-resources-vue.js', 'typeAheadMixin'],
accountDetailMixin: [
'js/djaodjin-resources-vue.js', 'accountDetailMixin'],
userDetailMixin: [
'js/djaodjin-resources-vue.js', 'userDetailMixin'],
QueryAccountsByAffinity: [
'js/djaodjin-survey-vue.js', 'QueryAccountsByAffinity'],
QueryAccountsByAnswers: [
'js/djaodjin-survey-vue.js', 'QueryAccountsByAnswers'],
practicesListMixin: [
'js/djaopsp-resources-vue.js', 'practicesListMixin'],
})
],
resolve: {
fallback: {
"fs": require.resolve("fs"),
"http": require.resolve("stream-http"),
"https": require.resolve("https-browserify"),
"querystring": require.resolve("querystring-es3"),
"stream": require.resolve("stream-browserify"),
"url": require.resolve("url/"),
"util": require.resolve("util/")
},
modules: [path.resolve(__dirname, 'djaopsp/static/vendor')].concat(
confPaths.node_modules),
},
resolveLoader: {
modules: [path.resolve(__dirname, 'djaopsp/static/vendor')].concat(
confPaths.node_modules),
}
};