vue.config配置

const path = require('path');

const Timestamp = new Date().getTime();

const VerNumber = '0.0.0.1'

var webpack = require('webpack')

module.exports = {

  publicPath: "./",

  outputDir: "dist",

chainWebpack: config => {

    config.module

         .rule('css')

         .test(/\.css$/)

         .oneOf('vue')

         .resourceQuery(/\?vue/)

         .use('px2rem')

         .loader('px2rem-loader')

         .options({

                 remUnit: 75

         })

},

  css: {

    // 配置css模块

    loaderOptions: {

      // 向预处理器 Loader 传递配置选项

      less: {

        // 配置less(其他样式解析用法一致)

        javascriptEnabled: true // 设置为true

      }

    }

  },

  configureWebpack: { // webpack 配置

    output: {

      filename: `[name].${VerNumber}.${Timestamp}.js`,

      chunkFilename: `[name].${VerNumber}.${Timestamp}.js`,

    },

    plugins: [

      new webpack.ProvidePlugin({

        $: 'jquery',

        jQuery: 'jquery',

        'window.jQuery': 'jquery',

        'root.jQuery': 'jquery'

      })

    ]

  },

  productionSourceMap: false,

  devServer: {

    open: "Chrome",

    port: 8099,

    host: "0.0.0.0",

    proxy: {

      "/api": {

        target: "http://xxxxxxxxx",

        changeOrigin: true,

        pathRewrite: { "^/api": "" }

      }

    }

  },

  pluginOptions: {

    'style-resources-loader': {

      preProcessor: 'less',

      patterns: [path.resolve(__dirname, './src/assets/less/global.less')]

    }

  }

};

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • HTML5面试题总结1.基础问题 = 和 == 和 === 的区别?= : 用于赋值 == : 用于判断 === ...
    LorenaLu阅读 5,092评论 0 4
  • const path = require("path"); const projectname = process...
    殇城阡陌阅读 4,385评论 0 0
  • webpack是什么 webpack可以看做是模块打包机:它做的事情是,分析你的项目结构,找到JavaScript...
    Q_骑猪看夕阳阅读 5,506评论 0 1
  • 版权声明:本文为博主原创文章,未经博主允许不得转载。 webpack介绍和使用 一、webpack介绍 1、由来 ...
    it筱竹阅读 13,864评论 0 21
  • 我是黑夜里大雨纷飞的人啊 1 “又到一年六月,有人笑有人哭,有人欢乐有人忧愁,有人惊喜有人失落,有的觉得收获满满有...
    陌忘宇阅读 12,759评论 28 53

友情链接更多精彩内容