-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
68 lines (66 loc) · 1.73 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
const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
let devMode = false;
if (typeof (process.env.NODE_ENV) != 'undefined') {
const devMode = process.env.NODE_ENV !== "production";
}
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js?t=' + new Date().getTime(),
chunkFilename: '[name]-chunk.js?t=' + new Date().getTime(),
path: path.resolve(__dirname, 'public'),
},
module: {
rules: [
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
use: ['file-loader']
},
{
test: /\.less$/i,
use: [
"style-loader",
"css-loader",
"less-loader",
"postcss-loader",
],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html'
}),
new CopyPlugin({
patterns: [
{from: "src/images", to: "images"},
{context: 'src/styles/otf/', from: "*", to: "."},
{context: 'src/styles/ttf/', from: "*", to: "."},
{context: 'src/styles/woff/', from: "*", to: "."},
{context: 'src/styles/svg/', from: "*", to: "."}
]
}),
new CompressionPlugin({
test: /\.js(\?.*)?$/i,
algorithm: "gzip",
compressionOptions: {
level: 9
}
})
].concat(devMode ? [] : [new MiniCssExtractPlugin()]),
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
compress: true,
port: 8888,
},
};