css-async-process-webpack-plugin

2.0.0 • Public • Published

css-async-process-webpack-plugin

NPM version Build Status

A webpack plugin for change the insert position of async loading style which is generated by mini-css-extract-plugin

Install

npm i -D css-async-process-webpack-plugin

NOTE: Should add after mini-css-extract-plugin

Usage

In your webpack configuration (webpack.config.js):

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssAsyncProcessWebpackPlugin = require('css-async-process-webpack-plugin');

module.exports = {
    //...
    plugins: [
        new MiniCssExtractPlugin({
            filename: "[name].[hash:8].css",
            chunkFilename: "[id].[hash:8].css"
        }),
        new CssAsyncProcessWebpackPlugin(),
    ]
}

Options

process

Function.
Change the async loading style insert before document.getElementById("less:theme:color") by default. You can change the logic by setting process.

new CssAsyncProcessWebpackPlugin({
    process: (source) => {
        return source.replace(/head.appendChild\(linkTag\)/, 'head.insertBefore(linkTag, document.getElementById("less:theme:color"))');
    }
}),

Package Sidebar

Install

npm i css-async-process-webpack-plugin

Weekly Downloads

5

Version

2.0.0

License

MIT

Unpacked Size

6.45 kB

Total Files

7

Last publish

Collaborators

  • kingller