Like node-sass-glob-importer except also parses vaguer paths without the .scss or .sass extension (like vendors/**/*)
npm install node-sass-glob-importer-plusscss
// Import all files inside the scss directory and subdirectories.
@import: 'scss/*/.scss';
`
Usage
`js
const sass = require('node-sass');
const globImporter = require('node-sass-glob-importer');
sass.render({
...
importer: globImporter()
...
});
`
$3
`js
// webpack.config.js
const globImporter = require('node-sass-glob-importer');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
module: {
rules: [
{
test: /\.scss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader'
}, {
loader: 'sass-loader',
options: {
sassOptions: {
importer: globImporter()
}
}
}
]
}
]
},
plugins: [
new MiniCssExtractPlugin({
filename: 'style.css'
})
]
}
`
$3
`bash
node-sass --importer node_modules/node-sass-glob-importer/dist/cli.js -o dist src/index.scss
`
Upgrade from 3.x.x to 5.x.x
It is not possible anymore to set the includePaths` option when initializing the importer. Use the node-sass includePaths option instead.