vue.config.js模板

  关于vue cli3.0中vue.config.js的配置,我看着官网走了一遍,整理了一下,因为配置项比较多,所以有的我就没放,给出了链接。(可以看链接里面自己配置哦)

// vue.config.js
module.exports = {
    // type :string  defalut :"/"
    // 把开发服务器架设在根路径
    publicPath: process.env.NODE_ENV === 'produvtion'
    ? '/production-sub-path/'
    : '/',

    // type :string  defalut :"dist"
    // 打包后的文件夹名字
    outputDir: 'dist',

    // type :string  defalut :""
    // 静态资源目录
    assetsDir: 'assets',

    // type :string  defalut :"index.html"
    // 指定生成的 index.html 的输出路径 (相对于 outputDir)。也可以是一个绝对路径。
    indexPath: 'index.html',

    // type :boolean  defalut :"true"
    // 生成的静态资源在它们的文件名中包含了 hash 以便更好的控制缓存,如果是vue cli创建的index.html,则为true,无法使用 Vue CLI 生成的 index HTML,为false
    filenameHashing: true,

    // type :object  defalut :"undefined"
    // 设置单页面与多页面
    // 多页面情况下,每个“page”应该有一个对应的 JavaScript 入口文件。其值应该是一个对象,对象的 key 是入口的名字,value 是:
        // 一个指定了 entry, template, filename, title 和 chunks 的对象 (除了 entry 之外都是可选的);
        // 或一个指定其 entry 的字符串。
    // 具体情况看官网 https://cli.vuejs.org/zh/config/#pages
    pages: {
        index: {
            // page 的入口
            entry: 'src/main.js',
            // 模板来源
            template: 'public/index.html',
            // 在 dist/index.html 的输出
            filename: 'index.html',
            // 当使用 title 选项时,
            // template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %>
            title: 'Index Page',
            // 在这个页面中包含的块,默认情况下会包含
            // 提取出来的通用 chunk 和 vendor chunk。
            chunks: ['chunk-vendors', 'chunk-common', 'index']
          }
    },

    // type :boolean| error defalut :"true"
    // 是否在开发环境下通过 eslint-loader 在每次保存时 lint 代码
        // true: eslint-loader 会将 lint 错误输出为编译警告。默认情况下,警告仅仅会被输出到命令行,且不会使得编译失败,在开发和生产环境都会起作用
            // 想要在生产构建时禁用 eslint-loader  ==>  lintOnSave: process.env.NODE_ENV !== 'production'
        // false:无反应
        // error:这会强制 eslint-loader 将 lint 错误输出为编译错误,同时也意味着 lint 错误将会导致编译失败。
        // 通过设置让浏览器 overlay 同时显示警告和错误 在 devServe 配置项中  ==>  overlay: {warnings: true,errors: true}
    lintOnSave: true,

    // type :boolean defalut :"false"
    // 是否使用包含运行时编译器的 Vue 构建版本。设置为 true 后你就可以在 Vue 组件中使用 template 选项了,但是这会让你的应用额外增加 10kb 左右。
        // 具体信息看官网 https://cn.vuejs.org/v2/guide/installation.html#运行时+编译器vs.只包含运行时
    runtimeCompiler: false,

    // type :Array defalut :"[]" (RegExp) ==> 正则
    // 默认情况下 babel-loader 会忽略所有 node_modules 中的文件。如果你想要通过 Babel 显式转译一个依赖,可以在这个选项中列出来
    transpileDependencies: [],

    // type :boolean  defalut :"true"
    // SourceMap 一个存储源代码与编译代码对应位置映射的信息文件
    // 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建
    productionSourceMap: true,

    // type :String  defalut : undefined
    // 设置生成的 HTML 中 
                    
                    

你可能感兴趣的:(vue.config.js模板)