0.0.20 • Published 3 years ago

@barusu-react/rollup-config v0.0.20

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

npm version npm download npm license

Install

yarn add --dev @barusu-react/rollup-config

Usage

  • Use in rollup.config.js

    • import path from 'path'
      import {
        createPreprocessorConfig,
        createRollupConfig,
      } from '@barusu-react/rollup-config'
      import manifest from './package.json'
      
      const resolvePath = p => path.resolve(__dirname, p)
      const paths = {
        source: {
          stylesheetInput: [
            resolvePath('src/style/index.styl'),
          ],
          assetsRoot: resolvePath('src/assets'),
        },
        eslintrc: resolvePath('.eslintrc.js'),
        tsconfig: resolvePath('tsconfig.src.json'),
      }
      
      const preprocessorConfig = createPreprocessorConfig({
        input: paths.source.stylesheetInput,
        pluginOptions: {
          multiEntryOptions: {
            exports: false,
          },
          postcssOptions: {
            modules: {
              localsConvention: 'camelCase',
            },
          }
        },
      })
      
      const config = createRollupConfig({
        manifest,
        pluginOptions: {
          typescriptOptions: {
            tsconfig: paths.tsconfig,
          },
          postcssOptions: {
            extract: false,
            minimize: true,
            modules: {
              localsConvention: 'camelCase',
              generateScopedName: 'barusu-[local]',
            },
            pluginOptions: {
              postcssUrlOptions: {
                url: 'inline',
                basePath: paths.source.assetsRoot,
              }
            },
          }
        }
      })
      
      const resolvedConfig = [preprocessorConfig, config]
      
      export default resolvedConfig

Examples

Options

preprocessOptions

Options of createRollupConfig

  • useSourceMap: Whether to generate sourceMap (includes declarationMap)

    • type: boolean
    • default: true
  • externalAllDependencies: Whether to exhaust all dependencies (include dependencies of child dependency)

    • type: boolean
    • default: true
  • manifest

    propertytyperequireddescription
    sourcestringtruesource entry file
    mainstringfalsetarget entry file of cjs
    modulestringfalsetarget entry file of es
    dependencies{[key: string]: string}falseignore these dependencies (external)
  • pluginOptions

    propertyrequireddescription
    jsonOptionsfalseoptions for @rollup/plugin-json
    nodeResolveOptionsfalseoptions for @rollup/plugin-node-resolve
    typescriptOptionsfalseoptions for rollup-plugin-typescript2
    commonjsOptionsfalseoptions for @rollup/plugin-commonjs
    peerDepsExternalOptionsfalseoptions for rollup-plugin-peer-deps-external
    postcssOptionsfalseoptions for @barusu-react/rollup-plugin-postcss-dts