-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
94 lines (84 loc) · 2.1 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
const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const path = require('path')
const modoDev = process.env.NODE_ENV !== 'production';
module.exports = {
mode: modoDev ? 'development' : 'production',
entry: {
main: [
'./src/main.js'
]
},
output: {
filename: 'assets/js/[name].js',
path: path.resolve(__dirname, 'public'),
},
devtool: 'eval-source-map',
module: {
rules: [{
test: /\.s[ac]ss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}, {
test: /\.(png|svg|jpg|gif)$/i,
use: ['file-loader']
}, {
test: /\.html$/i,
type: "assets/resource"
}
],
},
plugins: [
new MiniCssExtractPlugin({
filename: "assets/css/style.css"
}),
new CopyPlugin({
patterns: [{
from: './src/index.html',
to: path.resolve(__dirname, 'public')
}, {
context: path.resolve(__dirname),
from: "./src/assets/html",
to: path.resolve(__dirname, 'public/assets/html')
}, {
from: './src/assets/img',
to: path.resolve(__dirname, 'public/assets/img')
}, {
from: './src/assets/js',
to: path.resolve(__dirname, 'public/assets/js')
}, {
from: './src/controller',
to: path.resolve(__dirname, 'public/controller')
}, {
from: './src/services',
to: path.resolve(__dirname, 'public/services')
}, {
from: './src/assets/upload',
to: path.resolve(__dirname, 'public/assets/upload')
}, {
from: './src/server.js',
to: path.resolve(__dirname, 'public')
}]
})
],
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6,
}
}),
new HtmlMinimizerPlugin()
]
},
devServer: {
static: {
directory: ("./public")
},
compress: true,
port: 9000
}
};