zoukankan      html  css  js  c++  java
  • vue-cli + webpack自动生成项目

    # 全局安装 vue-cli
    $ npm install --global vue-cli
    # 创建一个基于 webpack 模板的新项目
    $ vue init webpack palanWebsite
    # 安装依赖,走你
    $ cd palanWebsite
    $ npm install
    $ npm run dev

    创建过程参考:https://www.2cto.com/kf/201711/695061.html,单元测试选择的是jest

    创建好的项目结构如下:

    下面就重点分析build和config目录下各个配置文件的解析:

    config目录下的各项配置都是为了服务webpack的配置,给不同的编译条件提供配置

    config/index.js

    'use strict'
    
    const path = require('path')
    
    module.exports = {
      dev: {
    
        // Paths
        assetsSubDirectory: 'static',
        assetsPublicPath: '/',
        proxyTable: {},
    
        // Various Dev Server settings
        host: 'localhost', // can be overwritten by process.env.HOST
        port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
        autoOpenBrowser: false,
        errorOverlay: true,
        notifyOnErrors: true,
        poll: false, 
    
        useEslint: true,
        showEslintErrorsInOverlay: false,
    
        /**
         * Source Maps
         */
    
        // https://webpack.js.org/configuration/devtool/#development
        devtool: 'cheap-module-eval-source-map',
    
        cacheBusting: true,
    
        cssSourceMap: true
      },
    
      build: {
        // 在任何模块文件内部,可以使用__dirname变量获取当前模块文件所在目录的完整绝对路径。
        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',
    
        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
      }
    }

    详解:http://www.cnblogs.com/whkl-m/p/6627864.html

  • 相关阅读:
    4.2说说计算机中的异常
    1.1组合电路、时序电路在计算机课程中的地位
    EFM32JG系列MCU内部温度传感器使用方法
    +7虚拟内存的作用,通过什么方式提高虚拟内存的性能
    +6存储结构是怎样提高性能的,它和局部性的关系是什么。
    +5性能分析定律
    +4 高速缓存
    +3软件优化至关重要,软件优化一般有哪些方法?
    +2流水线是怎样提高性能的,会遇到什么问题,解决方法是什么
    +1阿姆达尔定律
  • 原文地址:https://www.cnblogs.com/xuepei/p/8329706.html
Copyright © 2011-2022 走看看