const { defineConfig } = require("@vue/cli-service")
const Version = new Date().getTime()
const { title } = require("./src/config")
process.env.VUE_APP_TITLE = title || "快益通"
// 是否为生产环境
const isProduction = process.env.NODE_ENV !== "development"
module.exports = defineConfig({
	transpileDependencies: false,
	lintOnSave: !isProduction, // eslint设置
	productionSourceMap: false, // 生产环境下css 分离文件
	devServer: {
		port: 8080,
		proxy: {
			"/api/v2/pdms": {
				target: process.env.VUE_APP_BASE_API,
				ws: true,
				changeOrigin: true,
				secure: false,
				headers: {
					Referer: process.env.VUE_APP_BASE_API
				}
			}
		}
	},
	css: {
		// 是否使用css分离插件 ExtractTextPlugin
		extract: {
			// 修改打包后css文件名
			filename: `static/css/[name].${Version}.css`,
			chunkFilename: `static/css/[name].${Version}.css`
		}
	},
	configureWebpack: {
		output: {
			filename: `static/js/[name].${Version}.js`,
			chunkFilename: `static/js/[name].${Version}.js`
		}
	}
	/*chainWebpack(config) {
		// img的文件名修改
		config.module
			.rule("images")
			.use("url-loader")
			.tap(options => {
				options.name = `static/img/[name].${Version}.[ext]`
				options.fallback = {
					loader: "file-loader",
					options: {
            name: `static/img/[name].${Version}.[ext]`
          }
        }
        return options
      })
  }*/
})
