其他分享
首页 > 其他分享> > vue打包assetsPublicPath为‘./‘和‘/abc/‘的两种情况

vue打包assetsPublicPath为‘./‘和‘/abc/‘的两种情况

作者:互联网

vue 测试 和正式环境打包 (npm run build)
assetsPublicPath路径可以设置为大致两种在nginx代理的方式也各有差异

第一种: assetsPublicPath: ‘ ./’

		location / {
			root /home/lw/hy/admin/dist;
			index index.html index.htm;
			autoindex on;
			expires  30m;
		}
		

第二种: assetsPublicPath: ‘/qbcd/’

			location /qbcd{
				 alias /home/lw/hy/admin/dist;
                  index index.html index.php index.htm;
				autoindex on;
				expires  30m;
			} 
	打包配置文件
 build: {
    prodEnv: require('./prod.env'),
    testEnv: require('./test.env'),
    // Template for index.html
    index: path.resolve(__dirname, '../dist/index.html'),
    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
     assetsPublicPath: '/hy/',
    /**
     * Source Maps
     */
    productionSourceMap: true,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  }

标签:npm,index,abc,dist,html,assetsPublicPath,vue,build
来源: https://blog.csdn.net/qq_44021541/article/details/117443631