美文网首页
Vue项目 --- 打包上线

Vue项目 --- 打包上线

作者: V火力全开 | 来源:发表于2018-07-16 15:27 被阅读0次

    执行下面命令:

    npm run build
    

    dist目录就是打包生成的目录,后端将dist的文件,放到可以访问的路径下,就可以了。

    我们也可以配置打包配置项,打开/config/index.js

    build: {
        // Template for index.html
        index: path.resolve(__dirname, '../dist/index.html'),
    
        // Paths
        assetsRoot: path.resolve(__dirname, '../dist'),
        assetsSubDirectory: 'static',
        assetsPublicPath: '/',
    
        /**
         * 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
      }
    

    我们通过配置assetsPublicPath来控制在后端的访问路径。

    相关文章

      网友评论

          本文标题:Vue项目 --- 打包上线

          本文链接:https://www.haomeiwen.com/subject/svdbpftx.html