-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvue.config.js
91 lines (90 loc) · 2.56 KB
/
vue.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
const { defineConfig } = require("@vue/cli-service");
const webpack = require("webpack"); // 引入 webpack 以使用 DefinePlugin 插件
module.exports = defineConfig({
transpileDependencies: true,
outputDir: "dist_electron",
pluginOptions: {
electronBuilder: {
preload: "preload.js",
builderOptions: {
win: {
icon: "src/assets/icons/icon.ico",
},
mac: {
icon: "src/assets/icons/icon.png",
},
linux: {
icon: "src/assets/icons/icon.png",
},
nsis: {
oneClick: false, // 禁用一键安装
allowToChangeInstallationDirectory: true, // 允许用户选择安装路径
createDesktopShortcut: true, // 创建桌面快捷方式
shortcutName: "XCMusic", // 快捷方式名称
},
},
},
},
configureWebpack: {
// 添加 DefinePlugin 插件来定义 Vue 的特性标志
plugins: [
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: JSON.stringify(true), // 启用 Options API
__VUE_PROD_DEVTOOLS__: JSON.stringify(false), // 禁用生产环境中的 Vue DevTools
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false), // 禁用生产环境的 hydration mismatch 错误详细信息
}),
],
resolve: {
alias: {
"@": require("path").resolve(__dirname, "src"), // 将 @ 指向 src 目录
},
extensions: [".js", ".vue", ".json"], // 确保 .js 扩展名会被解析
},
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/], // 为 vue 文件增加 .ts 处理
happyPackMode: true,
},
},
},
{
test: /\.js$/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-typescript"],
plugins: ["@babel/plugin-proposal-nullish-coalescing-operator"],
},
},
},
{
test: /\.m?js$/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
plugins: ["@babel/plugin-proposal-nullish-coalescing-operator"],
},
},
},
{
test: /\.md$/,
use: "raw-loader",
},
{
test: /\.txt$/,
use: "raw-loader",
},
],
},
devServer: {
port: 4321,
host: "localhost",
},
},
});