-
Notifications
You must be signed in to change notification settings - Fork 55
/
webpack.config.js
129 lines (128 loc) · 2.91 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssoWebpackPlugin = require('csso-webpack-plugin').default;
const CopyPlugin = require('copy-webpack-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
module.exports = {
entry: {
scripts: [
'./source/js/app.js',
'./source/sass/style.scss',
'./source/index.html'
]
},
resolve: {
extensions: [".js", ".sass", ".scss", ".css"],
modules: ['./node_modules/'],
},
mode: 'development',
devtool: `source-map`,
devServer: {
host: '0.0.0.0',
contentBase: path.join(__dirname, 'build'),
port: 7777
},
output: {
path: path.join(__dirname, 'build'),
publicPath: '',
filename: 'js/script.js'
},
module: {
rules: [
{
test: /\.s[a|c]ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
sourceMap: true,
url: false
},
},
{
loader: "sass-loader",
options: { sourceMap: true },
}
],
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: "css-loader",
options: {
sourceMap: true,
url: false
},
},
],
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
options: {
attributes: false
}
},
{
loader: 'posthtml-loader',
options: {
plugins: [
require('posthtml-include')({ root: 'source' })
]
}
}
]
}
]
},
plugins: [
new WriteFilePlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'source/index.html',
}),
new MiniCssExtractPlugin({
filename: 'css/style.min.css',
chunkFilename: "[id].css"
}),
new CssoWebpackPlugin({
pluginOutputPostfix: 'min'
}),
new CopyPlugin([
{
from: "source/fonts/**/*.{woff,woff2}",
to: path.join(__dirname, 'build', 'fonts'),
flatten: true,
},
{
from: "source/img/**",
to: path.join(__dirname, 'build'),
transformPath(targetPath) {
return targetPath.replace(`source${path.sep}`, '');
},
},
{
from: "source/*.ico",
to: path.join(__dirname, 'build'),
flatten: true,
},
{
from: "source/3d/**",
to: path.join(__dirname, 'build'),
transformPath(targetPath) {
return targetPath.replace(`source${path.sep}`, '');
},
}
]),
]
};