create-rollup-config

2.0.2 • Public • Published

rollup常用plugin基本配置

提供alias,eslint,resolve,common,babel,replace,postcss等基本插件,引入方可传入同名属性进行相应的plugin配置(见使用


dev模式

提供了基本的启动服务以及热更新功能,服务启动在http://127.0.0.1:8080,热更新默认监听./src目录

生产环境

提供uglify和filesize功能

使用

安装

yarn add cerate-rollup-config --dev

使用

// rollup.config.js
const path = require('path')
const baseConfig = require('create-rollup-config');

const config = baseConfig({
    alias: {
        $common: './src/common'
    },
    replace: {
        env: JSON.stringify(process.env.NODE_ENV)
    },
    serve: {
        port: 7001
    },
    livereload: {
        watch: '/src' // default
    }
})

export default [
    {
        input: './src/test.js',
        output: [
            {
                file: 'dist/test.js',
                format: 'cjs'
            }
        ],
        ...config
    }
]

package.json配置

{
    ...,
    "scripts": {
        "build": "cross-env NODE_ENV=production rollup -c ./rollup.config.js",
        "server": "cross-env NODE_ENV=development rollup -c ./rollup.config.js --watch",
        ...
    },
    ...
}

部分plugin介绍

postcss

默认开启了minimize功能

参考:rollup-config-postcss

html

将html文件转为字符串,并支持压缩

参考:rollup-plugin-string-html

License

MIT © hyhappy

Readme

Keywords

Package Sidebar

Install

npm i create-rollup-config

Weekly Downloads

1

Version

2.0.2

License

MIT

Unpacked Size

9.7 kB

Total Files

16

Last publish

Collaborators

  • hyhappy