-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.babel.js
118 lines (113 loc) · 3.3 KB
/
webpack.common.babel.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
import path from 'path';
import webpack from 'webpack';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import WriteFileWebpackPlugin from 'write-file-webpack-plugin';
import pkgInfo from 'pkginfo';
pkgInfo(module);
const config = {
target: 'web',
node: {
fs: 'empty'
},
entry: {
index: `./src/scripts/${module.exports.name}/js/index.js`
},
performance: {
hints: false
},
externals: {
jquery: 'jQuery'
},
optimization: {
splitChunks: {
name: true,
cacheGroups: {
index: {
test: /static\/js/
},
vendors: {
test: /([\\/]node_modules[\\/])/,
name: 'vendor',
chunks: 'all'
}
}
}
},
module: {
rules: [
{
test: /\.(ttf|eot|woff|woff2)/,
loader: 'file-loader',
options: {
name: `images/${module.exports.name}/fonts/[name].[ext]`,
}
},
{
test: /\.(png|svg|gif)$/,
loader: 'file-loader',
exclude: [
'/images/img/guardian.png'
],
options: {
name: `images/${module.exports.name}/[name].[ext]`,
},
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
},
{
test: /\.(html)$/,
use: {
loader: 'html-loader'
}
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
],
plugins: [
'@babel/plugin-transform-modules-amd',
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-runtime'
]
}
}
}
]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
createDayLabel: "jquery",
createWeekdayLabel: "jquery"
}),
// Page fragment definitions go here
new HtmlWebpackPlugin({
template: `src/{{ps_category}}/{{ps_location}}/{{page}}.{{app_name}}.content.footer.txt`,
PS_URL: 'https://ps.irondistrict.org',
filename: `{{ps_category}}/{{ps_location}}/{{page}}.{{app_name}}.content.footer.txt`,
chunks: ['vendor', 'index'],
inject: false
}),
new WriteFileWebpackPlugin({
test: /(admin|teachers|guardian|public|wildcards)/
})
],
resolve: {
modules: ['src', 'node_modules'],
extensions: ['.js', '.mjs']
}
};
export default config;