forked from meine-stadt-transparent/meine-stadt-transparent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.common.js
136 lines (133 loc) · 4.43 KB
/
webpack.config.common.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
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 path = require('path');
const fs = require('fs');
const webpack = require('webpack');
const BundleTracker = require('webpack-bundle-tracker');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const merge = require('webpack-merge');
module.exports = {
context: path.resolve(__dirname),
entry: {
mainapp: '../mainapp/assets/js/index',
persons: '../mainapp/assets/js/persons',
calendar: '../mainapp/assets/js/calendar',
},
output: {
path: path.resolve(__dirname, '../mainapp/assets/bundles/'),
filename: (process.env.NODE_ENV === 'production' ? '[name]-[hash].js' : '[name].js'),
publicPath: "",
},
devtool: 'source-map',
module: {
rules: [{
test: /\.scss$/,
use: [
MiniCssExtractPlugin.loader, {
loader: 'css-loader',
options: {
sourceMap: true,
}
}, {
loader: 'resolve-url-loader',
options: {
sourceMap: true
}
}, {
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
[
'autoprefixer',
{},
],
],
},
sourceMap: true
}
}, {
loader: 'sass-loader',
options: {
sourceMap: true
}
}]
}, {
test: /\.js$/,
exclude: /(node_modules\/bootstrap-daterangepicker\/)/,
use: {
loader: 'babel-loader',
options: {
"presets": ["@babel/preset-env"],
sourceMap: true
}
}
}, {
test: /\.(jpe?g|gif|png)$/,
use: {
loader: 'file-loader',
options: {
"outputPath": "images",
"name": "[name].[ext]"
}
} // adding -[hash] would be better, but seems to lead to problems with default leaflet markers
}, {
test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
use: {
loader: 'file-loader',
options: {
"name": "[name].[ext]"
}
}
}, {
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
resolve: {
alias: {
'jquery': path.join(__dirname, '../node_modules/jquery/dist/jquery'),
}
},
plugins: [
new BundleTracker({
path: path.resolve(__dirname, '../mainapp/assets/bundles'),
filename: './webpack-stats.json'
}),
new MiniCssExtractPlugin({
filename: process.env.NODE_ENV === 'production' ? '[name]-[contenthash].css' : '[name].css'
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"Hammer": "hammerjs/hammer",
"Popper": "popper.js",
"L": "leaflet"
}),
],
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
},
},
},
},
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development'
};
let customization_folder = "./customization/";
fs.readdirSync(customization_folder).forEach((dir) => {
let configFile = customization_folder + dir + '/webpack.config.js';
if (dir !== 'etc' && fs.existsSync(customization_folder + dir + '/webpack.config.js')) {
try {
// Hint: require works relative to the directory of this file (etc/),
// while fs.readdirSync relative to the project root, therefore this . -> .. trick
module.exports = merge(module.exports, require('.' + configFile));
console.log("Using extra configuration: " + configFile);
} catch (e) {
console.error('Could not read file: ' + configFile)
}
}
});