UNPKG

3 kBMarkdownView Raw
1# webpack-handle-css-loader
2
3[![NPM version](https://img.shields.io/npm/v/webpack-handle-css-loader.svg?style=flat-square)](https://npmjs.com/package/webpack-handle-css-loader) [![NPM downloads](https://img.shields.io/npm/dm/webpack-handle-css-loader.svg?style=flat-square)](https://npmjs.com/package/webpack-handle-css-loader) [![Build Status](https://img.shields.io/circleci/project/egoist/webpack-handle-css-loader/master.svg?style=flat-square)](https://circleci.com/gh/egoist/webpack-handle-css-loader) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat-square)](https://github.com/egoist/donate)
4
5This is a short-hand module for adding css and extracting css support.
6
7## Install
8
9```bash
10$ npm install --save webpack-handle-css-loader
11```
12
13## Usage
14
15```js
16const HandleCSSLoader = require('webpack-handle-css-loader')
17const ExtractTextPlugin = require('extract-text-webpack-plugin')
18
19const production = process.env.NODE_ENV === 'production'
20
21const handleLoader = new HandleCSSLoader({
22 minimize: production,
23 extract: production
24})
25
26module.exports = {
27 module: {
28 rules: [
29 // Handle .css files with css-loader & postcss-loader
30 handleLoader.css(),
31 // Handle .sass files
32 // Similar to above but add sass-loader too
33 handleLoader.sass()
34 ]
35 },
36 plugins: [
37 new ExtractTextPlugin('[name].[contenthash:8].css')
38 ]
39}
40```
41
42## API
43
44```js
45const handleLoader = new HandlerCSSLoader()
46```
47
48### new HandleCSSLoader([options])
49
50#### options
51
52##### minimize
53
54Type: `boolean`<br>
55Default: `undefined`
56
57Minimize CSS.
58
59##### extract
60
61Type: `boolean`<br>
62Default: `undefined`
63
64Extract CSS.
65
66##### sourceMap
67
68Type: `boolean` `string`<br>
69Default: `undefined`
70
71Enable sourcemaps.
72
73##### fallbackLoader
74
75Type: `string`<br>
76Default: `style-loader`
77
78##### cssLoader
79
80Type: `string`<br>
81Default: `css-loader`
82
83##### cssModules
84
85Type: `boolean`<br>
86Default: `undefined`
87
88Enable CSS modules.
89
90### handleLoader.getLoader(test, loader, options)
91
92#### test
93
94Type: `RegExp`
95
96#### loader
97
98Type: `string`
99
100Loader name or the path to it.
101
102#### options
103
104Type: `any`
105
106Loader options.
107
108### handleLoader.css()
109
110Alias to `handleLoader.getLoader(/\.css$/, 'css-loader')`
111
112### handleLoader.sass()
113
114### handleLoader.scss()
115
116### handleLoader.stylus()
117
118### handleLoader.styl()
119
120## Contributing
121
1221. Fork it!
1232. Create your feature branch: `git checkout -b my-new-feature`
1243. Commit your changes: `git commit -am 'Add some feature'`
1254. Push to the branch: `git push origin my-new-feature`
1265. Submit a pull request :D
127
128## Author
129
130**webpack-handle-css-loader** © [EGOIST](https://github.com/egoist), Released under the [MIT](https://egoist.mit-license.org/) License.<br>
131Authored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/webpack-handle-css-loader/contributors)).
132
133> [egoistian.com](https://egoistian.com) · GitHub [@egoist](https://github.com/egoist) · Twitter [@rem_rin_rin](https://twitter.com/rem_rin_rin)