This repository has been archived by the owner on Sep 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
66 lines (63 loc) · 1.52 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
const path = require("path");
const glob = require("glob");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const VueLoaderPlugin = require("vue-loader/lib/plugin");
function getEntries(pattern) {
const entries = {};
glob.sync(pattern).forEach(file => {
const ext = file.substr(file.lastIndexOf("."));
const name = file.substr(file.lastIndexOf("/") + 1);
const output = name.replace(ext, "");
entries[output] = path.join(__dirname, file);
});
return entries;
}
const webpackJS = {
mode: "production",
resolve: {
alias: {
"@scripts": path.resolve(__dirname, "src/vue"),
"@vue": path.resolve(__dirname, "src/vue")
}
},
entry: getEntries("src/scripts/*.js"),
output: {
path: path.join(__dirname, "src/assets"),
filename: "[name].js"
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: "babel-loader"
},
exclude: /node_modules/
},
{
test: /\.vue$/,
loader: "vue-loader"
},
{
test: /\.css$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{ loader: "css-loader", options: { importLoaders: 1 } },
{
loader: "postcss-loader",
options: {
config: { path: path.resolve(__dirname, "postcss.config.js") }
}
}
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
name: "[name].css"
}),
new VueLoaderPlugin()
]
};
module.exports = [{ ...webpackJS }];