const { resolve } = require('path')
const { name, version } = require('./package.json')
module.exports = {
  publicPath: "/",
  outputDir: process.env.NODE_ENV === 'production' ? "dist" : process.env.NODE_ENV === 'test' ? "test" : "dist",
  assetsDir: "static",
  lintOnSave: false, // 关闭eslint
  runtimeCompiler: true,
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src'))
  },
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'sass',
      patterns: [
        resolve(__dirname, './src/assets/styles/*.scss')      //你的.scss文件所在目录
      ]
    },
    // 桌面应用打包配置
    electronBuilder: {
      preload : 'src/preload.js',
      builderOptions: {
        // build配置在此处
        // options placed here will be merged with default configuration and passed to electron-builder
        "appId": "XXX",
        "directories": {
          "output": process.env.NODE_ENV === 'production' ? "dist_electron" : "test_electron" // 输出文件夹
        },
        "publish": [
          {
            "provider": "generic",
            "url": "https://pc.liebaoai.cn/download/",//更新服务器地址,可为空
          }
        ],
        "mac": {
          "icon": "./static/image/desk-logo.ico",
        },
        "win": {
          "icon": "./static/image/desk-logo.ico",
          "artifactName": `${name}-v${version}-setup.exe`,
          "target": [ { "target": "nsis", "arch": [ "x64", "ia32" ] } ] 
        },
        "linux": {
          "icon": "./static/image/desk-logo.ico",
          "artifactName": `${name}-v${version}-setup.exe`
        },
        // "asar": false,
        "nsis": {
          "oneClick": false,
          "guid": "猎豹AI聚合配送",
          "perMachine": true,
          "allowElevation": true,
          "allowToChangeInstallationDirectory": true,
          "installerIcon": "./static/image/desk-logo.ico",
          "uninstallerIcon": "./static/image/desk-logo.ico",
          "installerHeaderIcon": "./static/image/desk-logo.ico",
          "createDesktopShortcut": true,
          "createStartMenuShortcut": true,
          "shortcutName": process.env.NODE_ENV === 'production' ? "猎豹AI聚合配送" : "猎豹AI聚合配送测试版"
        }
      }
    }
  }
}