1.0.9 • Published 6 years ago

vue-cli-plugin-wieldy-webpack v1.0.9

Weekly downloads
29
License
MIT
Repository
github
Last release
6 years ago

vue-cli-plugin-wieldy-webpack

NPM version Known Vulnerabilities changelog license

npm-image

wieldy-webpack 迁移到 vue-cli 3.0 插件体系

使用方法

在 vue-cli3 创建的项目目录下执行

vue add wieldy-webpack

内置功能

  • 预备多套环境配置
    • 开发: development
    • 测试: test
    • 预上线: stage
    • 生产: production
  • 默认的 browserslist 配置
  • vue.config.js 从环境变量中获取 publicPath
  • 增强 webpack 配置
    • 根据文件的名称给动态分离的 chunk 命名
    • webpack runtime inline 到 html 文件中
    • 增加 layout 机制
    • 添加 banner 注释
    • 优化图片
    • 开启 mock server 功能
    • 调整 minimizer option

预留的环境变量

配置 layout 机制

如果想不指定 template 参数, 需要将 public/index.html 的内容清空或者只保留 <body> 中的内容

  • 给默认的单页配置 layout

    // vue.config.js
    pages: {
        main: {
            entry: 'src/main.js',
            filename: 'index.html',
            title: 'page title',
    
            _useLayout: {
                layoutFile: './src/layout.html' // 这里仅为示例, layout 文件需要自己去指定
            }
        }
    }
  • 多页配置 layout

    // vue.config.js
    var createPageConfig = require('vue-cli-plugin-wieldy-webpack/lib/create-page-config.js');
    
    pages: {
        ...createPageConfig('src/pages/a/a.js', {
            // page config
            title: 'page a'
        }, {
            // layout config
            layoutFile: './src/layout.html' // 这里仅为示例, layout 文件需要自己去指定
        }),
        ...createPageConfig('src/pages/b/b.js', {
            title: 'page b'
        }, {
            layoutFile: './src/layout.html' // 这里仅为示例, layout 文件需要自己去指定
        })
    }