-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
126 lines (124 loc) · 3.86 KB
/
webpack.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
const path = require('path');
const webpack = require("webpack");
const PolyfillInjectorPlugin = require('webpack-polyfill-injector');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const DotEnv = require("dotenv-webpack");
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
resolve: {
alias: {
'node_modules': path.join(__dirname, 'node_modules'),
'bower_modules': path.join(__dirname, 'bower_modules')
}
},
entry: {
index: `webpack-polyfill-injector?${JSON.stringify({
modules: ['./src/index.js']
})}!`,
list: `webpack-polyfill-injector?${JSON.stringify({
modules: ['./src/list/index.js']
})}!`,
status: `webpack-polyfill-injector?${JSON.stringify({
modules: ['./src/status/index.js']
})}!`,
resources: `webpack-polyfill-injector?${JSON.stringify({
modules: ['./src/resources/index.js']
})}!`,
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new DotEnv({systemvars: true}),
new CopyPlugin([
{ from: './src/config.json', to: path.resolve(__dirname, 'dist') },
]),
new CleanWebpackPlugin(),
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: "[id].css"
}),
new HtmlWebpackPlugin({
filename: 'index.html',
inject: true,
chunks: ['index'],
template: '!ejs-loader!src/index.html'
}),
new HtmlWebpackPlugin({
filename: 'list/index.html',
inject: true,
chunks: ['list'],
template: '!ejs-loader!src/index.html'
}),
new HtmlWebpackPlugin({
filename: 'status/index.html',
inject: true,
chunks: ['status'],
template: '!ejs-loader!src/index.html'
}),
new HtmlWebpackPlugin({
filename: 'resources/index.html',
inject: true,
chunks: ['resources'],
template: '!ejs-loader!src/index.html'
}),
new PolyfillInjectorPlugin({
polyfills: [
'Promise',
'fetch',
'Object.values',
'Array.prototype.findIndex'
]
})
],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
publicPath: "/",
libraryTarget: 'umd',
library: '[name]',
globalObject: 'this',
umdNamedDefine: true
},
module: {
rules: [
{
test: /\.(css)$/,
use: ['style-loader', MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.(html)$/,
use: {
loader: 'html-loader',
options: {
attrs: ['img:src', ':data-src'],
options: {
minimize: true
}
}
}
},
{
test: /\.(woff(2)?|ttf|eot|svg|xml|png)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader',
options: {
name: '[hash]_[name].[ext]',
outputPath: 'assets'
}
},
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
}
}
}
]
}
};