Search code examples
webpackpostcss

Can Webpack build PostCSS without a JavaScript file?


I have some a general, reusable stylesheet to build that is not associated with a single JavaScript file. Is it possible for Webpack to process a PostCSS file directly? Such as:

module.exports = {
    module: {
        loaders: [
            { test: /\.pcss$/, loader: "postcss" },
        ]
    },
    output: {
        path: "/css/",
        filename: '[name].css'
    },
    entry: {
        bootstrap: 'pcss/base/styles.pcss'
    }
};

Solution

  • You can implement simple workaround by using file-loader:

    entry: {
        bootstrap: 'file?name=[name].[ext]!pcss/base/styles.pcss'
    }
    

    In this case your file will be saved separately from the entry point.