Skip to content

基于mini-css-extract-plugin,根据less全局设置分离出多份css文件,打包出多份css文件,packed into multiple css according to different global less

License

Notifications You must be signed in to change notification settings

jiang43605/multiple-mini-css-extract-plugin

This branch is 5 commits ahead of, 363 commits behind webpack-contrib/mini-css-extract-plugin:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
蒋玮乘
Jan 14, 2019
67d54c7 · Jan 14, 2019

History

93 Commits
May 7, 2018
May 7, 2018
Nov 12, 2018
Oct 2, 2018
Aug 6, 2018
May 7, 2018
Mar 26, 2018
May 7, 2018
Mar 28, 2018
Mar 3, 2018
May 7, 2018
Oct 10, 2018
Feb 28, 2018
Jan 14, 2019
May 7, 2018
May 7, 2018
Sep 1, 2018
Oct 10, 2018
Nov 13, 2018

Repository files navigation

Base

https://github.com/webpack-contrib/mini-css-extract-plugin

features

  • compatible with mini-css-extract-plugin (100% case pass)
  • packed into multiple css according to different global less

dependency

less-loader

use

npm i multiple-mini-css-extract-plugin

 {
    ...
    module: {
        rules: [
            {
                test: /\.less$/,
                use: [
                    {
                        loader: miniCssExtractPlugin.loader,
                        options: {
                            less: [
                                {
                                    filename: 'pccss/[name].[contenthash].css',
                                    publicPath: publicPath || '/'
                                    globalVars: {},
                                    modifyVars: {
                                        '@primary-color': 'red',
                                    }
                                },
                                {
                                    filename: 'phonecss/[name].[contenthash].css',
                                    publicPath: publicPath || '/'
                                    globalVars: {},
                                    modifyVars: {
                                        '@primary-color': 'green',
                                    }
                                }
                            ],

                            // the old way(compatible), in order to take effect, 
                            // you must remove less option 
                            // publicPath: publicPath || '/'
                        }
                    },
                    {
                        loader: 'css-loader'
                    },
                    {
                        loader: 'less-loader'
                    }
                    ...
                ]
            }
        ]
    }

    ...

     new miniCssExtractPlugin({
        // this option does not take effect when you specify 'less' option in loader
        filename: '[name].[contenthash].css',
    })
}

then you can see it in the directory:

pccss
    - index.7d4112a0ee983e1028ba.css
    - vendors.87f0392908854a20e1ff.css
phonecss
    - index.7d4112a0ee983e1028ba.css
    - vendors.87f0392908854a20e1ff.css

About

基于mini-css-extract-plugin,根据less全局设置分离出多份css文件,打包出多份css文件,packed into multiple css according to different global less

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 86.1%
  • CSS 10.7%
  • HTML 3.2%