This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
82 lines (77 loc) · 1.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
const path = require("path");
const merge = require("webpack-merge");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const VueSsrClientPlugin = require("vue-server-renderer/client-plugin");
const VueSsrServerPlugin = require("vue-server-renderer/server-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const pkg = require("./package.json");
// A helper to create paths relative to this config file
function p(...paths) {
return path.join(__dirname, ...paths);
}
const babel = {
loader: "babel-loader",
options: {
presets: [["env", { modules: false, targets: { uglify: true } }]],
plugins: ["transform-object-rest-spread"]
}
};
const css = [MiniCssExtractPlugin.loader, "css-loader"];
const base = {
output: {
path: p("build"),
filename: "assets/[chunkhash].js",
publicPath: "/"
},
module: {
rules: [
{
test: /\.js$/,
include: [p("src")],
use: [babel]
},
{
test: /\.vue$/,
include: [p("src")],
loader: "vue-loader",
options: {
loaders: {
js: babel,
css: css,
scss: [...css, "sass-loader"]
},
postcss: [require("autoprefixer")()]
}
},
{
test: /\.(eot|woff2|woff|ttf|svg|png)$/,
loader: "file-loader",
options: {
outputPath: "assets/"
}
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: "assets/[chunkhash].css"
}),
new CompressionPlugin()
]
};
module.exports = [
merge(base, {
entry: p("src/frontend/browser-entry.js"),
plugins: [new VueSsrClientPlugin()],
devtool: "source-map"
}),
merge(base, {
target: "node",
entry: p("src/frontend/server-entry.js"),
output: {
libraryTarget: "commonjs2"
},
externals: Object.keys(pkg.dependencies),
plugins: [new VueSsrServerPlugin()]
})
];