-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·112 lines (103 loc) · 3.42 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
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
module.exports = {
// base source path
context: path.resolve(__dirname, 'src'),
// entry file names to compile
entry: {
app: [
'./js/app.js',
'./scss/main.scss'
]
},
// compiled files path
output: {
filename: "js/[name].js",
path: path.resolve(__dirname, 'dist'),
publicPath: "../"
},
// enable source maps
devtool: 'inline-source-map',
// directory for starting webpack dev server
devServer: {
contentBase: './'
},
// connect other plugins
plugins: [
new MiniCssExtractPlugin({filename: "./css/[name].css"}),
new CopyWebpackPlugin([{from: './img/', to: './img/'}]),
new ImageminPlugin({ test: /\.(jpe?g|png|gif)$/i }),
// jQuery global plugin
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery',
web3: 'web3',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default'],
})
],
// optimizing configuration
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin({}),
]
},
// setting up file extensions handlers
module: {
rules: [
// Styles loader
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
// Image loader (for styles)
{
test: /\.(png|jpe?g|gif)$/,
loaders: [
{
loader: 'file-loader',
options: {name: '[path][name].[ext]'},
},
{
loader: 'img-loader',
options: {
plugins: [
require('imagemin-gifsicle')({
interlaced: false
}),
require('imagemin-mozjpeg')({
progressive: true,
arithmetic: false
}),
require('imagemin-pngquant')({
floyd: 0.5,
speed: 2
}),
require('imagemin-svgo')({
plugins: [
{removeTitle: true},
{convertPathData: false}
]
})
]
}
}
]
},
// SVG converter into 'data:image'
{
test: /\.svg$/,
loader: 'svg-url-loader',
},
]
}
};