项目nginx部署到非根目录下vue配置

1、修改config/index.js

项目nginx部署到非根目录下vue配置_第1张图片

2、修改路由route/index

项目nginx部署到非根目录下vue配置_第2张图片

3、若index.html有引入static中的 js 和images需要配置 webpack.dev.conf.js 和 webpack.prod.conf.js

        配置webpack.dev.conf.js ,大概在55行左右增加path配置

new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'index.html',
      inject: true,
      path: config.dev.assetsPublicPath + config.dev.assetsSubDirectory
    }),

       配置webpack.prod.conf.js ,大概在65行左右增加path配置

new HtmlWebpackPlugin({
      filename: config.build.index,
      template: 'index.html',
      inject: true,
      path: config.build.assetsPublicPath + config.build.assetsSubDirectory,
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
        // more options:
        // https://github.com/kangax/html-minifier#options-quick-reference
      },
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }),

4、配置好后再来看一下index.html引入js吧

    
    
    

5、引入static中的图片具体方法参考https://blog.csdn.net/lilongwei4321/article/details/82783523

你可能感兴趣的:(vue)