前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >2019-08-22 vue3.0的vue.config.js 文件

2019-08-22 vue3.0的vue.config.js 文件

作者头像
用户4344670
发布2019-08-28 11:34:27
1.1K0
发布2019-08-28 11:34:27
举报
文章被收录于专栏:vue的实战vue的实战
代码语言:javascript
复制
const webpack = require('webpack')
const TerserPlugin = require('terser-webpack-plugin')  // 用于在生成环境剔除debuger和console
const path = require('path');
const resolve = dir => {
    return path.join(__dirname, dir);
};



module.exports = {

    // 用于引入jquery开始
    lintOnSave: false,
    configureWebpack: {
        plugins: [
            new webpack.ProvidePlugin({
                $: "jquery",
                jQuery: "jquery",
                "windows.jQuery": "jquery"
            })
        ],

    },
    // 用于引入jquery结束
    publicPath: './',
    outputDir: './dist',
    lintOnSave: false, // 关闭eslint
    // 打包时不生成.map文件
    productionSourceMap: false,
    devServer: {
        open: true,
        host: '0.0.0.0',
        port: 8808 ///   修改端口号
        // 由于本项目数据通过easy-mock和mockjs模拟,不存在跨域问题,无需配置代理;
        // proxy: {
        //   '/v2': {
        //       target: target,
        //       changeOrigin: true
        //   }
        // }
    },

    // webpack相关配置
    chainWebpack: (config) => {
        config.entry.app = ['./src/main.js']
        config.resolve.alias
            .set('@', resolve('src'))
            .set('cps', resolve('src/components'))
        // 关闭npm run build之后,This can impact web performance 警告
        config.performance
            .set('hints', false)
    },
    configureWebpack:config => {
        // 为生产环境修改配置...
        if (process.env.NODE_ENV === 'production') {
            new TerserPlugin({
                cache: true,
                parallel: true,
                sourceMap: true, // Must be set to true if using source-maps in production
                terserOptions: {
                    compress: {
                        drop_console: true,
                        drop_debugger: true
                    }
                }
            })
        } else {
            // 为开发环境修改配置...

        }

    },


}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019.08.22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档