You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
5.1 KiB

const webpack = require('webpack');
const path = require('path');
4 years ago
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
publicPath: './',
// 生产环境打包不输出 map
productionSourceMap: false,
4 years ago
devServer: {
disableHostCheck: true,
port: process.env.DEV_SERVER_PORT || 8080,
proxy: {
'^/api': {
target:
// 'https://service-osrz4um8-1257251314.gz.apigw.tencentcs.com/release/',
'http://127.0.0.1:3000/',
changeOrigin: true,
pathRewrite: {
'^/api': '/',
},
},
'^/meting': {
target: 'https://api.wuenci.com/meting/api/',
changeOrigin: true,
pathRewrite: {
'^/meting': '/',
},
},
},
4 years ago
},
pwa: {
name: 'YesPlayMusic',
4 years ago
iconPaths: {
favicon32: 'img/icons/favicon-32x32.png',
4 years ago
},
themeColor: '#ffffff00',
4 years ago
manifestOptions: {
background_color: '#335eea',
4 years ago
},
// 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'],
4 years ago
},
},
chainWebpack(config) {
config.module.rules.delete('svg');
config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end();
4 years ago
config.module
.rule('icons')
4 years ago
.test(/\.svg$/)
.include.add(resolve('src/assets/icons'))
4 years ago
.end()
.use('svg-sprite-loader')
.loader('svg-sprite-loader')
4 years ago
.options({
symbolId: 'icon-[name]',
4 years ago
})
.end();
config.module
.rule('napi')
.test(/\.node$/)
.use('node-loader')
.loader('node-loader')
.end();
// LimitChunkCountPlugin 可以通过合并块来对块进行后期处理。用以解决 chunk 包太多的问题
config.plugin('chunkPlugin').use(webpack.optimize.LimitChunkCountPlugin, [
{
maxChunks: 3,
minChunkSize: 10_000,
},
]);
4 years ago
},
// 添加插件的配置
pluginOptions: {
// electron-builder的配置文件
electronBuilder: {
4 years ago
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: {
4 years ago
target: [
4 years ago
{
target: 'dmg',
arch: ['x64', 'arm64', 'universal'],
4 years ago
},
4 years ago
],
artifactName: '${productName}-${os}-${version}-${arch}.${ext}',
category: 'public.app-category.music',
darkModeSupport: true,
},
win: {
4 years ago
target: [
{
target: 'portable',
arch: ['x64'],
4 years ago
},
{
target: 'nsis',
arch: ['x64'],
4 years ago
},
],
publisherName: 'YesPlayMusic',
icon: 'build/icons/icon.ico',
publish: ['github'],
},
linux: {
4 years ago
target: [
{
target: 'AppImage',
arch: ['x64'],
4 years ago
},
{
target: 'tar.gz',
arch: ['x64', 'arm64'],
4 years ago
},
{
target: 'deb',
arch: ['x64', 'armv7l', 'arm64'],
4 years ago
},
{
target: 'rpm',
arch: ['x64'],
4 years ago
},
{
target: 'snap',
arch: ['x64'],
4 years ago
},
{
target: 'pacman',
arch: ['x64'],
4 years ago
},
],
category: 'Music',
icon: './build/icon.icns',
},
dmg: {
icon: 'build/icons/icon.icns',
},
nsis: {
4 years ago
oneClick: true,
4 years ago
perMachine: true,
4 years ago
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')
);
},
// 渲染线程的配置文件
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: []
},
},
4 years ago
};