Skip to content

mazemax/import-glob-loader2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Glob Loader

Globbing preloader for Webpack

Install

npm install --save-dev import-glob-loader2

Detail

Expands globbing patterns for import statements. Currently only does vertical expansion, e.g.
@import "foo/**/*";

Expands into

@import "foo/1.scss";
@import "foo/bar/2.scss";
@import "foo/bar/3.scss";

Usage

You can use it one of two ways, the recommended way is to use it as a preloader for files you know has import statements. This usually applies to ES6 module `import` statements, CSS `@import` at-rules, and Sass `@import` statements.
// Webpack 2:

module: {
 rules: [
   {
     test: /\.scss/,
     enforce: "pre",
     loader: "import-glob-loader2"
   },
   // ...
 ]
}

// Webpack 1:
 
{
  module: {
    preLoaders: [{
      test: /\.scss/,
      loader: 'import-glob-loader2'
    }]
  }
}

Options

All options are passthrough to [node-glob](https://github.com/isaacs/node-glob). `import-glob` comes with two additional options.
  • test = 'import' The test for globbing to be applied. Lines matching test will be expanded. (This is a word-boundary test, so import will match @import but not importScript, for example)
  • delimiter = '\n' The delimiter used to join expanded globs.

Maintainer(s)

M.Saad Siddiqui