webpack-glob-loader
v1.0.0
Published
ES6 import with glob patterns (preload for Webpack)
Downloads
372
Readme
webpack-glob-loader
ES6 import with glob patterns (preload for Webpack)
(Forked from https://github.com/fred104/webpack-import-glob-loader)
Expands globbing patterns for ES6 import
statements.
import modules from "./foo/**/*.js";
Expands into
import * as module0 from "./foo/1.js";
import * as module1 from "./foo/bar/2.js";
import * as module2 from "./foo/bar/3.js";
const modules = [module0, module1, module2]
For importing from node module
import modules from "a-node-module/**/*js";
Expands into
import * as module0 from "a-node-module/foo/1.js";
import * as module1 from "a-node-module/foo/bar/2.js";
import * as module2 from "a-node-module/foo/bar/3.js";
const modules = [module0, module1, module2]
For side effects:
import "./foo/**/*.scss";
Expands into
import "./foo/1.scss";
import "./foo/bar/2.scss";
For sass:
@import "./foo/**/*.scss";
Expands into
@import "./foo/1.scss";
@import "./foo/bar/2.scss";
Install
npm install --save-dev webpack-glob-loader
Usage
// ./webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
enforce: 'pre',
loader: 'webpack-glob-loader'
},
{
test: /\.s[ac]ss$/i,
enforce: 'pre',
use: [
{ loader: 'webpack-glob-loader' }
]
}
// ...etc.
]
// ...etc.
}
// ...etc.
}