2.0.3 • Published 3 years ago

rollup-plugin-css-chunks v2.0.3

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

rollup-plugin-css-chunks

Rollup plugin to extract imported CSS files as chunks, allowing code split of CSS stylesheets. Use rollup-plugin-extract-bundle-tree to extract dependencies between JS and CSS chunks.

Installation

npm install --save-dev rollup-plugin-css-chunks

Features

  • Split CSS in chunks;
  • Load CSS map referenced or embedded on sourceMappingURL;
  • Return CSS chunk public URL;

Usage

import css_chunk_url from './home.css';

const css_chunk_map_url = css_chunk_url + '.map';
console.log({css_chunk_url, css_chunk_map_url})

Configuration

// rollup.config.js
import css from 'rollup-plugin-css-chunks';

export default {
    input: 'src/main.js',
    output: {
        dir: 'public',
        format: 'esm'
    },
    plugins: [
        css({
            // inject a CSS `@import` directive for each chunk depended on
            injectImports: false,
            // name pattern for emitted secondary chunks
            chunkFileNames: '[name]-[hash].css',
            // name pattern for emitted entry chunks
            entryFileNames: '[name].css',
            // public base path of the files
            publicPath: '',
            // generate sourcemap
            sourcemap: false,
            // emit css/map files
            emitFiles: true,
        })
    ]
}

License

MIT

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.2.9

3 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago