vue.config.js 2.63 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)
}
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");

module.exports = {
    publicPath: './',
    chainWebpack: (config) => {
        //自定义路径 alias
        config.resolve.alias
            .set('@', resolve('src'))
            .set('@api', resolve('src/api'))
            .set('@assets', resolve('src/assets'))
            .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'))
    },
    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: [
          // 去除console和debugger
          // new UglifyJsPlugin({
          //   uglifyOptions: {
          //     compress: {
          //       drop_console: true,
          //       drop_debugger: true,
          //     },
          //   },
          //   parallel: true,
          // }),
        //     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: "192.168.2.61",
      port: 8008,
      https: false,
      hotOnly: false,
      proxy: {
        "/api": {
          // target: 'https://192.168.2.119:8006', //泽平 
          // target: process.env.VUE_APP_api1, //本地
          target: process.env.VUE_APP_api, //赵千
          // target: process.env.VUE_APP_api4, //赵千
          changeOrigin: true,
          pathRewrite: {
            "^/api": "/",
          },
        },
      }, // 设置代理
      before: (app) => {
        console.log(app);
      },
    },
}