-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
113 lines (101 loc) · 3.4 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
107
108
109
110
111
112
113
const { ProvidePlugin } = require('webpack');
const path = require('path');
const { resolve, join } = require('path');
const autoprefixer = require('autoprefixer');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const sourceDirectory = resolve(__dirname, 'src');
const staticFilesDirectory = resolve(__dirname, 'static');
const buildDirectory = resolve(__dirname, 'deploy');
module.exports = (env) => {
const isProduction = env.production;
const publicPath = '/';
const imagesLocation = 'images';
return {
context: sourceDirectory,
entry: {
main: path.resolve(__dirname, './src/app.js'),
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader']
},
{
test: /\.(s(a|c)ss)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
},
{
test: /\.(woff|woff2|eot|ttf|svg|jpg|png)$/,
use: {
loader: 'url-loader',
},
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx'],
alias: {
'../../theme.config$': path.join(__dirname, 'semantic-theme/theme.config'),
'../../icons': path.join(__dirname, 'node_modules/semantic-ui-sass/icons'),
}
},
plugins: [
new MiniCssExtractPlugin(),
new CopyWebpackPlugin({
patterns: [
{ from: imagesLocation, to: imagesLocation },
{ from: staticFilesDirectory, to: buildDirectory },
],
}),
new ImageminPlugin({
disable: !isProduction,
test: `${imagesLocation}/**`,
optipng: {
optimizationLevel: 5,
},
jpegtran: {
progressive: true,
},
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './index.html',
}),
new HtmlWebpackPlugin({
filename: 'about.html',
template: './about.html',
}),
new HtmlWebpackPlugin({
filename: 'coc.html',
template: './coc.html',
}),
new HtmlWebpackPlugin({
filename: 'faq.html',
template: './faq.html',
}),
new HtmlWebpackPlugin({
filename: 'travel.html',
template: './travel.html',
}),
// new HtmlWebpackPlugin({
// filename: 'remo.html',
// template: './remo.html',
// }),
new ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
}),
],
output: {
path: path.resolve(__dirname, 'deploy'),
filename: '[name].bundle.js',
publicPath
},
}
};