网页 综合 更新时间 2026-11-14 16:20:26

Advanced entry | webpack

自动蜘蛛 webpack.js.org 正文约 1511 字
Advanced entry | webpack
It is possible to provide different types of files when using an array of values for entry to achieve separate bundles for CSS and JavaScript (and other) files in applications that are not using import for styles in JavaScript (pre Single Page Applications or different reasons).
Let's make an example. We have a PHP application with two page types: home and account. The home page has different layout and non-sharable JavaScript with the rest of the application (account page). We want to output home.js and home.css from our application files for the home page and account.js and account.css for account page.
Webpack extracts CSS on its own, so sass-loader is the only loader needed — give the rule a CSS module type and webpack takes it from there.
Running webpack with above configuration will output into ./dist as we did not specify different output path. ./dist directory will now contain four files:
Copyright OpenJS Foundation and webpack contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | Bylaws | Code of Conduct | Trademark Policy | Trademark List | Cookie Policy
访问原文 返回搜索 https://webpack.js.org/guides/entry-advanced/
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。