1 | # node-sass-glob-importer
|
2 | [![Build Status](https://travis-ci.org/maoberlehner/node-sass-magic-importer.svg?branch=master)](https://travis-ci.org/maoberlehner/node-sass-magic-importer)
|
3 | [![GitHub stars](https://img.shields.io/github/stars/maoberlehner/node-sass-magic-importer.svg?style=social&label=Star)](https://github.com/maoberlehner/node-sass-magic-importer)
|
4 |
|
5 | Custom node-sass importer to which allows you to use glob syntax in imports
|
6 |
|
7 | Globbing allows pattern matching operators to be used to match multiple files at once.
|
8 |
|
9 | ```scss
|
10 | // Import all files inside the `scss` directory and subdirectories.
|
11 | @import: 'scss/**/*.scss';
|
12 | ```
|
13 |
|
14 | ## Usage
|
15 | ```js
|
16 | var sass = require('node-sass');
|
17 | var glopImporter = require('node-sass-glob-importer');
|
18 |
|
19 | sass.render({
|
20 | ...
|
21 | importer: glopImporter()
|
22 | ...
|
23 | });
|
24 | ```
|
25 |
|
26 | ### webpack
|
27 | ```js
|
28 | // webpack.config.js
|
29 | const globImporter = require('node-sass-glob-importer');
|
30 | const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
31 |
|
32 | module.exports = {
|
33 | module: {
|
34 | rules: [
|
35 | {
|
36 | test: /\.scss$/,
|
37 | use: ExtractTextPlugin.extract([
|
38 | {
|
39 | loader: 'css-loader'
|
40 | }, {
|
41 | loader: 'sass-loader',
|
42 | options: {
|
43 | importer: globImporter()
|
44 | }
|
45 | }
|
46 | ])
|
47 | }
|
48 | ]
|
49 | },
|
50 | plugins: [
|
51 | new ExtractTextPlugin({
|
52 | filename: 'style.css'
|
53 | })
|
54 | ]
|
55 | }
|
56 | ```
|
57 |
|
58 | ### CLI
|
59 | ```bash
|
60 | node-sass --importer node_modules/node-sass-glob-importer/dist/cli.js -o dist src/index.scss
|
61 | ```
|
62 |
|
63 | ## Upgrade from 3.x.x to 5.x.x
|
64 | It is not possible anymore to set the `includePaths` option when initializing the importer. Use the [node-sass includePaths option](https://github.com/sass/node-sass#includepaths) instead.
|
65 |
|
66 | ## Why is there no 4.x version?
|
67 | This module is maintained in [one repository](https://github.com/maoberlehner/node-sass-magic-importer) together with multiple other node-sass custom importers. The node-sass-magic-importer repository is using a [monorepo approach](https://medium.com/@maoberlehner/monorepos-in-the-wild-33c6eb246cb9) with fixed versions for all packages. The projects maintained in the node-sass-magic-importer monorepo started out as separate repositories with separate versioning, so when they were integrated into the monorepo, the versions of all projects were raised to 5.0.0 and are in sync since then.
|
68 |
|
69 | ## node-sass-magic-importer
|
70 | This module is powered by [node-sass-magic-importer](https://github.com/maoberlehner/node-sass-magic-importer).
|
71 |
|
72 | ## About
|
73 | ### Author
|
74 | Markus Oberlehner
|
75 | Website: https://markus.oberlehner.net
|
76 | Twitter: https://twitter.com/MaOberlehner
|
77 | PayPal.me: https://paypal.me/maoberlehner
|
78 |
|
79 | ### License
|
80 | MIT
|