forked from qier222/YesPlayMusic
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vue.config.js
208 lines (204 loc) · 5.36 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
const webpack = require('webpack');
const path = require('path');
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
// 生产环境打包不输出 map
productionSourceMap: false,
devServer: {
disableHostCheck: true,
port: process.env.DEV_SERVER_PORT || 8080,
proxy: {
'^/api': {
target: 'http://localhost:3000',
changeOrigin: true,
pathRewrite: {
'^/api': '/',
},
},
},
},
pwa: {
name: 'YesPlayMusic',
iconPaths: {
favicon32: 'img/icons/favicon-32x32.png',
},
themeColor: '#ffffff00',
manifestOptions: {
background_color: '#335eea',
},
// workboxOptions: {
// swSrc: "dev/sw.js",
// },
},
pages: {
index: {
entry: 'src/main.js',
template: 'public/index.html',
filename: 'index.html',
title: 'YesPlayMusic',
chunks: ['main', 'chunk-vendors', 'chunk-common', 'index'],
},
},
chainWebpack(config) {
config.module.rules.delete('svg');
config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end();
config.module
.rule('icons')
.test(/\.svg$/)
.include.add(resolve('src/assets/icons'))
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
.options({
symbolId: 'icon-[name]',
})
.end();
config.module
.rule('napi')
.test(/\.node$/)
.use('node-loader')
.loader('node-loader')
.end();
config.module
.rule('webpack4_es_fallback')
.test(/\.js$/)
.include.add(/node_modules/)
.end()
.use('esbuild-loader')
.loader('esbuild-loader')
.options({ target: 'es2015', format: "cjs" })
.end();
// LimitChunkCountPlugin 可以通过合并块来对块进行后期处理。用以解决 chunk 包太多的问题
config.plugin('chunkPlugin').use(webpack.optimize.LimitChunkCountPlugin, [
{
maxChunks: 3,
minChunkSize: 10_000,
},
]);
},
// 添加插件的配置
pluginOptions: {
// electron-builder的配置文件
electronBuilder: {
nodeIntegration: true,
externals: ['@unblockneteasemusic/rust-napi'],
builderOptions: {
productName: 'YesPlayMusic',
copyright: 'Copyright © YesPlayMusic',
// compression: "maximum", // 机器好的可以打开,配置压缩,开启后会让 .AppImage 格式的客户端启动缓慢
asar: true,
publish: [
{
provider: 'github',
owner: 'qier222',
repo: 'YesPlayMusic',
vPrefixedTagName: true,
releaseType: 'draft',
},
],
directories: {
output: 'dist_electron',
},
mac: {
target: [
{
target: 'dmg',
arch: ['x64', 'arm64', 'universal'],
},
],
artifactName: '${productName}-${os}-${version}-${arch}.${ext}',
category: 'public.app-category.music',
darkModeSupport: true,
},
win: {
target: [
{
target: 'portable',
arch: ['x64'],
},
{
target: 'nsis',
arch: ['x64'],
},
],
publisherName: 'YesPlayMusic',
icon: 'build/icons/icon.ico',
publish: ['github'],
},
linux: {
target: [
{
target: 'AppImage',
arch: ['x64'],
},
{
target: 'tar.gz',
arch: ['x64', 'arm64'],
},
{
target: 'deb',
arch: ['x64', 'armv7l', 'arm64'],
},
{
target: 'rpm',
arch: ['x64'],
},
{
target: 'snap',
arch: ['x64'],
},
{
target: 'pacman',
arch: ['x64'],
},
],
category: 'Music',
icon: './build/icon.icns',
},
dmg: {
icon: 'build/icons/icon.icns',
},
nsis: {
oneClick: true,
perMachine: true,
deleteAppDataOnUninstall: true,
},
},
// 主线程的配置文件
chainWebpackMainProcess: config => {
config.plugin('define').tap(args => {
args[0]['IS_ELECTRON'] = true;
return args;
});
config.resolve.alias.set(
'jsbi',
path.join(__dirname, 'node_modules/jsbi/dist/jsbi-cjs.js')
);
config.module
.rule('webpack4_es_fallback')
.test(/\.js$/)
.include.add(/node_modules/)
.end()
.use('esbuild-loader')
.loader('esbuild-loader')
.options({ target: 'es2015', format: "cjs" })
.end();
},
// 渲染线程的配置文件
chainWebpackRendererProcess: config => {
// 渲染线程的一些其他配置
// Chain webpack config for electron renderer process only
// The following example will set IS_ELECTRON to true in your app
config.plugin('define').tap(args => {
args[0]['IS_ELECTRON'] = true;
return args;
});
},
// 主入口文件
// mainProcessFile: 'src/main.js',
// mainProcessArgs: []
},
},
};