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

[POC] Eject feature #1916

Closed
wants to merge 1 commit into from
Closed

[POC] Eject feature #1916

wants to merge 1 commit into from

Conversation

banyan
Copy link
Contributor

@banyan banyan commented Jan 26, 2019

Hi! I want to pursue a possibility that if we can have eject feature in webpacker.

I understand webpacker can configure all of webpack settings using ConfigList and ConfigObject. If a use case is just simple, then we can go with webpacker without having many custom settings, but if we want to customize, eventually we have to understand internal webpacker codes. In that case, I think webpacker:eject would be useful especially who knows webpack well and wants to configure directly.

I believe webpacker:eject would be an escape route of a tall mountain. Even it might not be used, it will make people feel easy and it will strengthen webpacker. That being said, this PR is just POC and has a problem how to maintain the initial webpack.config.js. IMO, webpack.config.js is not need to be completely compatible with webpacker's one, but just core logic is enough.

eject will do following things:

  • Generete webpacker compatible webpack.config.js while referring to config/webpacker.yml's settings.
    • config/webpack/loaders/* will be used from generated webpack.config.js. so for example, if you run bundle exec rake webpacker:install:elm before, you can still use elm.
  • webpacker gem will have remained for asset helpers like javascript_pack_tag.
  • npm-scripts yarn start and yarn build will be added.

This PR works well with fresh rails new projects.

I'm happy if I can get any feedbacks.
@gauravtiwari I saw this. do you have any idea regarding implementation?

@jakeNiemiec
Copy link
Member

jakeNiemiec commented Jan 29, 2019

You beat me to it 😆, I had been working out an eject function for a while. I stopped because I felt like there needs to be a completely separate gem for resolving entry files/chunks from javascript_pack_tags.

Looks good!

@nikushi
Copy link

nikushi commented Apr 29, 2019

Very interesting work. FYI, I made WebpackManifest gem a while ago, which provides helpers to resolve path and chunk.

@h0jeZvgoxFepBQ2C
Copy link

Anyone knows if this PR will get merged?

@derekblank
Copy link

@banyan Updating lines 2, 10, 12, 14, and 33 of template.rb to use double-quoted strings will resolve the build failure.

@trcarden
Copy link
Contributor

trcarden commented Jul 2, 2019

Does this have support broadly from the rest of the rails team? Seems like an excellent idea and I would even say that if webpacker was just reconstructed into a set of generators it may be even better. We have to learn parts of webpack anyway and in order to know why our CSS is showing up inline instead of a file in dev you have to dive into webpacker to determine the config anyway.
See: #2161

@kimihito
Copy link

kimihito commented Jul 11, 2019

@banyan has extracted this PR as webpacker_ejetor gem 🎉

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

Successfully merging this pull request may close these issues.

8 participants