Legendary

李洋的学习笔记


项目部署发布

<ol> <li> <p>安装serve:<code>cnpm i serve -g</code></p> </li> <li> <p>构建生产环境下压缩打包的项目:<code>cnpm run build</code>,生成一个dist包</p> </li> <li>运行生产环境下的的项目页面index.html:<code>serve -s dist/</code></li> </ol> <h3>vue-cli 项目部署到码云page需要修改的配置:</h3> <ol> <li> <p>\build\build.js 中注释掉日志打印:</p> <pre><code>if (stats.hasErrors()) { //console.log(chalk.red(' Build failed with errors.\n')) process.exit(1) } /*console.log(chalk.cyan(' Build complete.\n')) console.log(chalk.yellow( ' Tip: built files are meant to be served over an HTTP server.\n' + ' Opening index.html over file:// won\'t work.\n' ))*/</code></pre> </li> <li> <p>\config\index.js 修改build模块中的路径 为相对路径:</p> <pre><code>build: { // Template for index.html index: path.resolve(__dirname, '../dist/index.html'), // Paths assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: './',</code></pre> </li> <li>\build\utils.js 新增publicPath: '../../': <pre><code>// Extract CSS when that option is specified // (which is the case during production build) if (options.extract) { return ExtractTextPlugin.extract({ use: loaders, fallback: 'vue-style-loader', publicPath: '../../', }) } else { return ['vue-style-loader'].concat(loaders) }</code></pre></li> </ol>

页面列表

ITEM_HTML