forked from frontend-park-mail-ru/2018_2_42
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
101 lines (96 loc) · 2.26 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
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const path = require('path');
const zopfli = require('@gfx/zopfli');
module.exports = {
mode: 'development',
entry: './public/js/main.js',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: './build.js'
},
module: {
rules: [
{
test: /\.xml$/,
use: [
{
loader: 'fest-webpack-loader'
}
]
},
{
test: /\.m?js$/,
exclude: /(node_modules)/,
use: [
{
loader: 'babel-loader',
options: {presets: [['@babel/preset-env']]}
}
]
},
{
test: /\.(woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=4096',
},
{
test: /\.(png|jpg|gif|svg|ico)$/,
loader: 'url-loader',
options: {
name: 'images/[name].[ext]',
limit: 4096
},
},
{
test: /\.ico$/,
loader: 'file-loader?name=images/favicon.ico',
},
{
test: /\.mp3$/,
loader: 'file-loader?name=audio/[name].[ext]',
},
{
test: /\.css$/,
use:['style-loader', MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']
},
{
test: /\.scss$/,
use:['style-loader', MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader','sass-loader']
},
]
},
plugins: [
new ServiceWorkerWebpackPlugin({
entry: path.join(__dirname, 'public/sw.js'),
}),
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin({}),
new CompressionPlugin({
compressionOptions: {
numiterations: 15
},
algorithm(input, compressionOptions, callback) {
return zopfli.gzip(input, compressionOptions, callback);
}
}),
new CleanWebpackPlugin('dist', {} ),
new MiniCssExtractPlugin({
filename: 'style.css',
}),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './public/index.html',
inject: false,
}),
]
};