Cross-domain front-end configuration in vue

1. Create vue.config.js in the root directory of the entire project, this file, and then write

const path = require('path')
const debug = process.env.NODE_ENV !== 'production'

module.exports = {     baseUrl:'/', // root domain context directory     outputDir:'dist', // build output directory     assetsDir:'assets', // static resource directory (js, css, img, fonts)     lintOnSave: false, // Whether to enable eslint save detection, valid value: ture | false |'error'     runtimeCompiler: true, // Does the runtime version need to be compiled     transpileDependencies: [], // The default babel-loader ignores mode_modules, and exceptions can be added here The dependent package name     productionSourceMap: true, // Whether to generate sourceMap file when building the production package, false will increase the speed of the build     configureWebpack: config => {// webpack configuration, the configuration is merged when the value is an object, and the configuration is rewritten when it is a method         if (debug) {// Development environment configuration             config.devtool ='cheap-module-eval-source-map'         } else {// Production environment configuration         }         // Object.assign(config, {// Development and production common configuration













        // resolve: {         // alias: {         //'@': path.resolve(__dirname,'.         / src'), //'@c': path.resolve(__dirname,'. /src/components') ,         //'vue$':'vue/dist/vue.esm.js'         //}         //}         // })     },     chainWebpack: config => {// webpack link API, used to generate and modify webapck configuration , Https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md         if (debug) {             // local development configuration         } else {             // production development configuration         }     },     parallel: require(' os').cpus().length> 1,// Open multi-process to process babel compilation during build
















    pluginOptions: {// Third-party plug-in configuration
    },
    pwa: {// Single-page plug-in related configuration https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
    } ,
    devServer: {         open: true,         host:'localhost',         port: 8081,         https: false,         hotOnly: false,         proxy: {// Configure cross-domain             '/api': {                 target:'http://localhost:5001 /api/',                 ws: true,                 changOrigin: true,                 pathRewrite: {                     '^/api':''                 }             }         },         before: app =>{ }
















    }
}
 

Guess you like

Origin blog.csdn.net/qq_21161977/article/details/112390052