Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack-Vue.config.js全局引入@时配置和gzip以及devServer #11

Open
PleaseStartYourPerformance opened this issue Nov 22, 2019 · 0 comments

Comments

@PleaseStartYourPerformance
Copy link
Owner

PleaseStartYourPerformance commented Nov 22, 2019

    chainWebpack: (config) => { 
//@代表外面的src哦
 config
            .resolve
            .alias
            .set('@', resolve('src'))
            .set('static', resolve('public/static'));

        config
            .plugin('gzip')
            .use(CompressionWebpackPlugin, [{
                algorithm: 'gzip',
                test: new RegExp(
                    '\\.(' + ['js', 'css'].join('|') +
                    ')$'
                ),
                threshold: 1024,
                minRatio: 0.8
            }])
   config.devServer
            .compress(true)
            .open(true)
            .proxy({
                    '/api': {
                    target: 'http://39.99.148.210:1001',
                    changeOrigin: true,
                    pathRewrite: {
                        '^/api': '/'
                    }
                }
            })
}

不使用链式

    devServer: {
        compress: true,
        open: false, //启动项目自动打开浏览器
        proxy: { //代理
            '/api': {
                target: 'http://192.168.0.37:3001',
                changeOrigin: true,
                pathRewrite: {
                    '^/api': '/'
                }
            }
        }
    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant