如何使用汇总

时间:2018-10-26 14:47:55

标签: postcss rollup

我当前正在使用RollupPostCSS。如何定位要处理的特定scss文件,而不必使用@import'source / scss / main.scss'in my source / js / entry.js`

例如做类似...的事情

// rollup.config.js
...
postcss({
        from: 'source/scss/main.scss'
        minimize: true,
        sourceMap: true, 
        extract : 'build/css/main.css'
    }),
...

而不是在source/js/entry.js

//source/js/entry.js
import  '../scss/main.scss'; // don't want to import SCSS from within JS file

import { someJSmodule } from './someJSmodule.js';
import { anotherJSmodule } from './anotherJSmodule.js';

这是我当前的rollup.config.js

// rollup.config.js
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import copy from 'rollup-plugin-copy';
import postcss from 'rollup-plugin-postcss';


export default {
    input: 'source/js/entry.js',
    output: {
        file: 'build/js/bundle.js',
        format: 'iife'
    },
    plugins: [
        copy({
            'source/index.html': 'build/index.html',
            verbose: true
        }),
        resolve({
            preferBuiltins: true
        }),
        postcss({
            minimize: true,
            sourceMap: true, 
            extract : 'build/css/main.css'
        }),
        commonjs(),
        babel({
            exclude: 'node_modules/**'
        })
    ]
};

0 个答案:

没有答案