Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add support for multiple files per entry #2476

Merged
merged 4 commits into from
Mar 16, 2020

Conversation

trcarden
Copy link
Contributor

@trcarden trcarden commented Mar 3, 2020

Add support for multiple files per entry

Summary

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).

For additional info: https://webpack.js.org/guides/entry-advanced/

Community Consideration

This is particularly useful if you are migrating from a per page
css/js organization as was common with rails <= 6

Note this has been a source of confusion and has been PR'd in the past as well. However no one pointed out this is a first class supported feature of webpack that is specifically built for static pages which rails does so well (see link above).

Here are just some of the PR/Issues from the past

PR changes

Seamlessly (without breaking support for the original single file per entry model) extends the entryPoint algo to extend entrypoints with multiple files when they are found.

So that you can get something like this

  'views/store/static/home': [
    '[redacted]/packs/views/store/static/home.js',
    '[redacted]/packs/views/store/static/home.scss'
  ]

and get a single pack with page specific js and css.

This is an updated PR originally from: #2213, made a mistake of issuing the PR from our master branch. Updated base to include 4.2.2 commits

Timothy Cardenas and others added 4 commits March 3, 2020 10:22
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).

For additional info: https://webpack.js.org/guides/entry-advanced/

This is particularly useful if you are migrating from a per page
css/js organization as was common with rails <= 6
@trcarden trcarden changed the title Add support for multiple files per entry Feature: Add support for multiple files per entry Mar 3, 2020
@gauravtiwari gauravtiwari merged commit 8d9b643 into rails:master Mar 16, 2020
@gauravtiwari
Copy link
Member

thanks @trcarden 🍰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants