This repository was archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
87 lines (85 loc) · 2.64 KB
/
webpack.config.js
File metadata and controls
87 lines (85 loc) · 2.64 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
// TODO remove when vue-cli-plugin-vue-next has ts support
const path = require("path");
const { VueLoaderPlugin } = require("vue-loader");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = (env = {}) => ({
mode: env.prod ? "production" : "development",
devtool: env.prod ? "source-map" : "cheap-module-eval-source-map",
entry: path.resolve(__dirname, "./src/main.ts"),
output: {
path: path.resolve(__dirname, "./dist"),
publicPath: "/dist/",
// See https://github.com/webpack/webpack/issues/6522
globalObject: "typeof self !== 'undefined' ? self : this",
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
alias: {
// See https://medium.com/@penx/managing-dependencies-in-a-node-package-so-that-they-are-compatible-with-npm-link-61befa5aaca7
vue: path.resolve("./node_modules/vue"),
"@vue": path.resolve("./node_modules/@vue"),
},
},
optimization: {
minimize: false,
usedExports: false /* We do this, because otherwise the build will be much slower than the development build for some reason */,
},
module: {
rules: [
{
test: /\.vue$/,
use: {
loader: "vue-loader",
options: {
templateCompilers: {
vugel: [require("vugel"), {}],
},
},
},
},
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/,
options: {
appendTsSuffixTo: [/\.vue$/],
},
},
{
test: /\.png$/,
use: {
loader: "url-loader",
options: { limit: 8192 },
},
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: { hmr: !env.prod },
},
"css-loader",
],
},
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre",
},
],
},
plugins: [
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: "[name].css",
}),
],
devServer: {
inline: true,
hot: false,
stats: "minimal",
contentBase: __dirname,
overlay: true,
},
});