vue.config.js 2.16 KB
//less全局配置
var path = require('path')
// const FileManagerPlugin = require('filemanager-webpack-plugin');
let Timestamp = new Date().getTime();
function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {
    publicPath: './',
    chainWebpack: (config) => {
        //自定义路径 alias
        config.resolve.alias
            .set('@', resolve('src'))
            .set('@api', resolve('src/api'))
            .set('@mixins', resolve('src/mixins'))
            .set('@store', resolve('src/store'))
            .set('@libs', resolve('src/libs'))
            .set('@router', resolve('src/router'))
            .set('@components', resolve('src/components'))
			.set('@assets', resolve('src/assets'))
    },
    pluginOptions: {
        'style-resources-loader': {
            preProcessor: 'less',
            patterns: [path.resolve(__dirname, './src/assets/less/public-class.less'), ]
        }
    },
    configureWebpack: { // webpack 配置,避免缓存js
        output: { // 输出重构  打包编译后的 文件名称  【模块名称.版本号.时间戳】
            filename: `js/[name].${Timestamp}.js`,
            chunkFilename: `js/[name].${Timestamp}.js`
        },
        // plugins: [

        //     new FileManagerPlugin({  //初始化 filemanager-webpack-plugin 插件实例
        //       onEnd: {
        //         mkdir: ['./zip','./dist'], //初始化生产zip和dist文件夹
        //         archive: [ //然后我们选择dist文件夹将之打包成dist.zip并放在dist文件下
        //           {source: './dist', destination: './zip/dist.zip'},//吧./dist文件夹里的文件打包成dist.zip包放在zip文件夹内
        //         ]
        //       }
        //     })
        // ]
    },
    devServer: {
      host: "0.0.0.0",
      port: 8008,
      https: false,
      hotOnly: false,
      proxy: {
        "/api": {
          //target: process.env.VUE_APP_api, //巍巍
           target: process.env.VUE_APP_api1, //本地
          changeOrigin: true,
          pathRewrite: {
            "^/api": "/",
          },
        },
      }, // 设置代理
      before: (app) => {
        console.log(app);
      },
    },
}