Solution:
var req = require.context("../someDir", true, /^(.*\.(js$))[^.]*$/igm);
req.keys().forEach(function(key){
req(key);
});
// or just: req.keys().forEach(req)
extra:
regex to match js
but ignore test.js
/^(?!.*test.js)((.*\.(js\.*))[^.]*$)/igm)
More Related Contents:
- What should I do to use this webpacked JS library? [closed]
- Passing environment-dependent variables in webpack
- “You may need an appropriate loader to handle this file type” with Webpack and Babel
- Calling webpacked code from outside (HTML script tag)
- Resolving require paths with webpack
- Angular 2: import external js file into component
- Static image src in Vue.js template
- What does “publicPath” in Webpack do?
- Using require(‘…’) with a variable vs. using a string in webpack
- How to bundle vendor scripts separately and require them as needed with Webpack?
- where is create-react-app webpack config and files?
- I am getting an “Invalid Host header” message when connecting to webpack-dev-server remotely
- Error: Missing class properties transform
- webpack –watch isn’t compiling changed files
- Can I use webpack to generate CSS and JS separately?
- Webpack Express Cannot Resolve Module ‘fs’, Request Dependency is Expression
- Module not found: Error: Can’t resolve vue, path not correct
- In the `import` syntax of ES6, how is a module evaluated exactly?
- Webpack not excluding node_modules
- Babel 7 – ReferenceError: regeneratorRuntime is not defined
- Path aliases for imports in WebStorm
- HtmlWebpackPlugin injects relative path files which breaks when loading non-root website paths
- how to set up an inline svg with webpack
- Node JS and Webpack Unexpected token
- Import ES module in Next.js ERR_REQUIRE_ESM
- Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Cannot find module ‘babel-preset-react’
- Conflict: Multiple assets emit to the same filename
- How to disable ESLint in vue-cli?
- Rails 5/6: How to include JS functions with webpacker?
- Solution: load independently compiled Webpack 2 bundles dynamically [closed]