-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
130 lines (117 loc) · 2.68 KB
/
webpack.config.js
File metadata and controls
130 lines (117 loc) · 2.68 KB
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
130
'use strict';
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const htmlWebpackPlugin = require("html-webpack-plugin");
const { VueLoaderPlugin } = require('vue-loader');
const CompressionPlugin = require("compression-webpack-plugin")
const config = {
mode: 'development',
entry: path.join(__dirname, "src", "scripts/app.js"),
output: {
path: path.join(__dirname, "dist"),
filename: "js/bundle.js"
},
devServer: {
contentBase: path.join(__dirname, "src"),
hot: false,
inline: true,
noInfo: false,
port: 3000,
proxy: {
"/api": "http://localhost:8080"
}
},
resolve: {
alias: {
styles: path.resolve(__dirname, "./src/styles/"),
scripts: path.resolve(__dirname, "./src/scripts/"),
images: path.resolve(__dirname, "./src/images/"),
vue: 'vue/dist/vue.common.js',
},
extensions: ['.js', '.vue', '.json', '.scss', '.css'],
},
module: {
rules: []
},
plugins: []
};
// babel
config.module.rules.push({
test: /\.js$/,
loader: "babel-loader",
exclude: "/node_modules/",
});
// vue
config.module.rules.push({
test: /\.vue$/,
loader: "vue-loader",
});
// fonts
config.module.rules.push({
test: /\.woff($|\?)|\.woff2($|\?)|\.ttf($|\?)|\.eot($|\?)|\.svg($|\?)/,
loader: 'file-loader',
options: {
publicPath: '../',
name: 'fonts/[name].[ext]',
}
});
// images
config.module.rules.push({
test: /\.(png|jpg|gif|jpeg)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'img/[name].[ext]',
useRelativePath: false,
outputPath: "",
publicPath: "../"
}
}
]
});
// html
config.module.rules.push({
exclude: /node_modules/,
include: /src\/*.html/,
loader: "raw-loader",
test: /\.html$/
});
// sass
config.module.rules.push({
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
//"style-loader",
"css-loader",
"sass-loader",
],
});
//
config.plugins.push(
new MiniCssExtractPlugin({
filename: "css/bundle.css",
})
);
// html
config.plugins.push(
new htmlWebpackPlugin({
template: "./src/index.html",
//inject: "body",
minify: false,
xhtml: true
})
);
// vue
config.plugins.push(
new VueLoaderPlugin()
);
// js compression
config.plugins.push(
new CompressionPlugin({
test: /\.(js|css)/,
asset: '[path].gz[query]',
algorithm: 'gzip'
})
);
module.exports = config;