-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.js
More file actions
149 lines (148 loc) · 5 KB
/
webpack.config.js
File metadata and controls
149 lines (148 loc) · 5 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
137
138
139
140
141
142
143
144
145
146
147
148
149
const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
devtool: 'eval-source-map',
entry: {
app: {
import: './munimap/frontend/js/app.js',
dependOn: 'vendor',
},
transport: {
import: './munimap/frontend/js/munimap_transport/app.js',
dependOn: 'vendor'
},
admin: {
import: './munimap/frontend/js/admin/admin.js',
dependOn: 'vendor'
},
static_app: {
import: './munimap/frontend/js/static-app.js',
dependOn: 'vendor'
},
vendor: ['angular', 'jquery', 'angular-ui-bootstrap'],
appStyle: {
import: './munimap/frontend/sass/appStyle.sass'
}
},
output: {
filename: 'js/[name].[contenthash].bundle.js',
path: path.resolve(__dirname, './munimap/static'),
chunkFilename: 'js/[name].[contenthash].bundle.js',
publicPath: '/',
},
resolve: {
alias: {
'ol': path.resolve('./node_modules/ol'),
'ol-ext': path.resolve('./node_modules/ol-ext'),
'bootstrap': path.resolve('./node_modules/bootstrap'),
'angular-ui-bootstrap': path.resolve('./node_modules/angular-ui-bootstrap'),
'jquery': path.resolve('./node_modules/jquery/src/jquery')
}
},
module: {
rules: [
// Small workaround for ace-builds to work.
// For some reason, the worker-javascript.js will be requested by ace under
// js/ace-builds/worker-javascript.js
// whereas the worker-yaml will be requested by ace under
// js/worker-yaml.js.
// So we handle the two files separately here and put them under different
// locations respectively.
{
test: /ace-builds.*worker-yaml\.js$/,
type: 'asset/resource',
generator: {
filename: 'js/[name].js'
}
},
{
test: /ace-builds.*worker-javascript\.js$/,
type: 'asset/resource',
generator: {
filename: 'js/ace-builds/[name].js'
}
},
{
test: /\.html$/,
use: ['html-loader']
},
{
test: /\.js$/,
exclude: /ace-builds.*worker-.*\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/env']
}
}
},
{
test: /\.s[ac]ss$/i,
use: [
// Extract CSS into own files
MiniCssExtractPlugin.loader,
// Translates CSS into CommonJS
{
loader: "css-loader",
options: {
url: false
}
},
{
loader: 'resolve-url-loader'
},
// Compiles Sass to CSS
{
loader: 'sass-loader',
options: {
sourceMap: true // important for resolve-url-loader
}
},
],
}
]
},
optimization: {
splitChunks: {
cacheGroups: {
defaultVendors: {
chunks: 'initial',
name: 'vendor',
test: 'vendor',
enforce: true
}
}
},
},
plugins: [
new MiniCssExtractPlugin({
filename: 'css/[name].[contenthash].css'
}),
new webpack.ProvidePlugin({
'window.jQuery': 'jquery',
$: 'jquery',
jQuery: 'jquery',
}),
new CopyPlugin({
patterns: [
{ from: "./munimap/frontend/css", to: path.resolve(__dirname, './munimap/static/css/[path][name].[contenthash][ext]') },
{ from: "./munimap/frontend/img", to: path.resolve(__dirname, './munimap/static/img') },
{ from: "./munimap/frontend/fonts", to: path.resolve(__dirname, './munimap/static/fonts') },
{ from: "./munimap/frontend/translations", to: path.resolve(__dirname, './munimap/static/translations/[path][name].[contenthash][ext]') }
],
}),
new WebpackManifestPlugin({
publicPath: ''
}),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [
'**/*',
'!\.gitkeep'
],
})
]
};