javascript - Webpack: Create a bundle with each file in directory -
i trying bundle every angular module in webpack. target have 1 app.js bundled webpack configuration:
entry: { app: "./app/app.js" }, output: { path: "./build/clientbin", filename: "bundle.js" },
i place bundle script in index.html entry point of app. have many modules in ./app/components
folder. folder structure in like:
app |--components | | | |--home | | | | | |--home.html | | |--home.js |--app.js |--appcontroller.js
i have required home.html
in home.js
when load home.js
of needed files load. problem have several components home
, want tell webpack bundle each component separately , name containing folder home
.
how can config webpack create these bundles , put them in ./build/components
?
a simpler way:
use globs in webpack.config.js
:
here's example:
var glob = require("glob"); module.exports = { entry: { js: glob.sync("./app/components/**/*.js"), } }
Comments
Post a Comment