A mobile terminal project was built with Vue (without vue.config.js), which could be normally opened by PC browser after running, but a blank screen was displayed when hbuilderX was run by mobile browser. The reason was that the resource path was loaded incorrectly, so a vue.config.js file was configured Change the publicPath to “./” and upload a vue.config.js configuration file as a whole for record
Code configuration
const path = require('path') const resolve = dir => path.join(__dirname, Dir) module.exports = {publicPath: process.env.node_env === 'production'? Defalut: dist outputDir: 'dist', // place generated static resources (js, CSS, img, fonts) in assetsDir (relative to outputDir), // specify the output path of generated index.html (relative to outputDir). It can also be an absolute path indexPath: 'index.html', // specify that the generated filename contains hash default: True, if you can't use VueCLI generated index HTML, you can turn off filenameHashing by setting this option to false: Eslint-loader lintOnSave: process.env.node_env === 'production', /* Whether to use the compiler default: False */ runtimeCompiler: false, // Whether to generate.map file when packing, defalut: true, set this to false to speed up packing productionSourceMap: True, / / two kind of way, watch their habit / / Type: Object | Function / / configureWebpack: {/ / resolve: {/ / alias: {/ / 'assets' : '@/assets', // 'components': '@/components' // } // } // }, chainWebpack: Config => {// Set the shortcut path, @ means' SRC ', Set ('@', resolve(' SRC ')). Set ('_c', Resolve (' SRC /components')) // Add loader to iView Switch and Circle /* config.module. rule(' Vue ').use('iview').loader('iview-loader').option({prefix: False}) */}, // CSS Related configuration CSS: {/* Enable CSS modules for all CSS/pre-processor files. */ modules: */ extract: true, /* Enable CSS source maps? */ sourceMap: False, // CSS presets loaderOptions: {CSS: {// the options here are passed to csS-loader}, sass: {// The options here will be passed to sasass-loader assuming you have the file 'SRC /variables. SCSS' // data: '@import "~@/variables. SCSS "; '}}}, // webpack-dev-server configuration devServer: {// port number: 8080, // whether to automatically start the browser open: false, // configure cross-domain proxy: {/* '/ API ': {// proxy path for example https://baidu.com target: 'https://baidu.com', // Change the origin of the host header to the destination URL changeOrigin: true, ws: True, pathRewrite: {' ^ / API ':'} / * * /} configure multiple cross-domain '/ foo: {target:' < other_url > '} * /}, / / PWA PWA plug-ins: {}, // pluginOptions: {}}Copy the code