This repository has been archived by the owner on May 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
159 lines (155 loc) · 4.27 KB
/
webpack.config.prod.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const webpack = require('webpack')
const pkg = require('./webpack.page.settings.js')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const path = require('path')
const extractStyles = new ExtractTextPlugin({ filename: pkg.dist_css+'[name].css' })
const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin')
var navDefaultClass = pkg.nav_default
var navClass = (pkg.headroom == true ? 'headroom' : navDefaultClass)
module.exports = {
entry: {
app: './src/app.js',
fonts: './src/fonts.js',
subpage: './src/subpage.js'
},
output: {
filename: pkg.dist_js+'[name].js',
path: path.resolve(__dirname, pkg.dist)
},
module: {
rules: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
use: [{
loader: 'babel-loader',
options: {
presets: [
['env', { modules: false }]
]
}
}]
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
exclude: [/fonts/],
loaders: ['file-loader?context=src/img&name=../'+pkg.src_tmp+'img-compressed/[path][name].[ext]', {
// loaders: ['lowercase-file', 'image-webpack-loader'],
loader: 'image-webpack-loader',
query: {
mozjpeg: {
progressive: true,
quality: 70
},
gifsicle: {
interlaced: false,
},
optipng: {
optimizationLevel: 7,
},
pngquant: {
quality: '75-85',
speed: 1
},
},
}],
include: __dirname,
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader?name=assets/fonts/[name].[ext]'
},
{
test: /\.html$/,
use: [ {
loader: 'html-loader',
options: {
minimize: true,
removeComments: true,
collapseWhitespace: true
}
}]
},
{
test: /\.css$/,
use: extractStyles.extract({
fallback: 'style-loader',
use: [
{
loader: "css-loader", // translates CSS into CommonJS
options: {
//modules: true,
//url: false //disable checking path to images etc.
}
},
{
loader: 'postcss-loader' //load autoprefixer
},
{
loader: 'resolve-url-loader'
},
]
})
},
{
test: /\.(scss)$/,
use: extractStyles.extract({
fallback: 'style-loader',
//resolve-url-loader may be chained before sass-loader if necessary
use: [
{
loader: "css-loader", // translates CSS into CommonJS
options: {
//modules: true,
url: false //disable checking path to images etc.
}
},
{
loader: 'postcss-loader' //load autoprefixer
},
{
loader: 'resolve-url-loader'
},
{
loader: "sass-loader" // compiles Sass to CSS
}
]
})
}
]
},
plugins: [
new CopyWebpackPlugin([
// Copy directory contents to {output}/to/directory/
{
from: pkg.src_tmp+'img-compressed/',
to: pkg.dist_img+'[path][name].[ext]'
}
// ,
// {
// from: './node_modules/ionicons/dist/fonts',
// to: pkg.dist_fonts
// }
// Copy glob results to /absolute/path/
//{ from: 'from/directory/**/*', to: '/absolute/path' },
], {
// ignore: [
// // Doesn't copy any files with a txt extension
// '*.txt',
// ],
// By default, we only copy modified files during
// a watch or webpack-dev-server build. Setting this
// to `true` copies all files.
copyUnmodified: true
}
),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
Popper: ['popper.js', 'default']
}),
extractStyles
]
};