Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { createFilter } from 'rollup-pluginutils';
- import { writeFile } from 'fs';
- import postcssrc from 'postcss-load-config';
- import postcss from 'postcss';
- export default (options = {}) => {
- if (!options.include) options.include = '**/*.css';
- const filter = createFilter(options.include, options.exclude);
- return {
- name: 'rollup-plugin-postcss',
- async transform(source, id) {
- if (!filter(id)) return;
- const filename = id.split('\\').pop().split('.').shift();
- const { plugins, options } = await postcssrc();
- const { css } = await postcss(plugins).process(source, { ...options, from: id, to: `public/${filename}.css` });
- writeFile(`public/${filename}.css`, css, () => true);
- return {
- code: '',
- map: null,
- };
- },
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement