Specifying A Complete Sub Directory In Webpack 2 Entry
I have a webpack 2 configuration as follows: module.exports = { context: __dirname, entry: [ './app.ts', './tab.ts', './client/clientService.ts',
Solution 1:
You can use a glob library like globule. globule.find
returns an array of the files. So you can use it as the entry:
entry: globule.find("./client/**/*.ts")
If you want to include other entry points as well you can combine them by spreading the returned array:
entry: [
'./other/entry.js'
...globule.find("./client/**/*.ts")
]
Or use any other way of combining the arrays (e.g. Array.prototype.concat
).
Alternatively you can use a single entry that imports everything you need with the help of require.context
as shown in the question webpack require every file in directory.
const req = require.context('./client/', true, /\.ts$/);
req.keys().forEach(req);
Post a Comment for "Specifying A Complete Sub Directory In Webpack 2 Entry"