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

Webpacker #319

Merged
merged 18 commits into from
Dec 9, 2020
Merged

Webpacker #319

merged 18 commits into from
Dec 9, 2020

Conversation

gmq
Copy link
Contributor

@gmq gmq commented Aug 28, 2020

Add support for ActiveAdmin in webpacker mode. (#298)

  • Uses rollup to generate the javascript used by sprockets
  • Updates javascript files to use es6 imports.
  • Adds generators to include the appropriate files when installing depending on how ActiveAdmin was installed.

TODO:

  • It assumes the npm package is going to be named "activeadmin_addons" How are we going to handle that release?
  • Tests
  • Potassium support will be handled separately.

For testing:

  • Clone this branch
  • Run yarn prepublishOnly inside cloned folder
  • In a new Rails installation add activeadmin and add this gem locally
    gem 'activeadmin_addons', path: '../activeadmin_addons'
  • Install activeadmin in webpacker mode
    bundle exec rails g active_admin:install --use_webpacker
  • Install activeadmin addons
    bundle exec rails g activeadmin_addons:install
    (ignore yarn error)
  • Install npm package
    yarn add ../activeadmin_addons

rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
rollup.config.js Show resolved Hide resolved
rollup.config.js Show resolved Hide resolved
app/assets/stylesheets/activeadmin_addons/all.scss Outdated Show resolved Hide resolved

begin
prepend_file("#{file_path}.scss", css_assets)
rescue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid rescuing without specifying an error class.


begin
inject_into_file("#{file_path}.js.coffee", coffee_assets, after: reference)
rescue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid rescuing without specifying an error class.

app/javascript/activeadmin_addons/all.js Outdated Show resolved Hide resolved
app/javascript/activeadmin_addons/all.js Show resolved Hide resolved
rollup.config.js Outdated Show resolved Hide resolved
@filipkis
Copy link

Thanks @gmq for this PR. Any update on this? What's still needed for it to get merged and released?

@nimarosa
Copy link

+1 Any updates on this? Can it be merged? I Am willing to help if anything is still needed.

@gmq gmq force-pushed the webpacker branch 7 times, most recently from 9ba9b10 to 47f717b Compare September 28, 2020 17:33
@gmq gmq changed the title [WIP] Webpacker Webpacker Oct 2, 2020
@hgeorgilas
Copy link

Is this going to be merged soon?
Thanks

@guiferrpereira
Copy link

excellent work here. can you tell when this will be merged?

@gmq
Copy link
Contributor Author

gmq commented Oct 5, 2020

I can't give a specific timeline, it still needs to be reviewed by the team and time is scarce these days. But it should be sooner rather than later!

@kwent
Copy link

kwent commented Oct 28, 2020

Looking forward to this ! Much needed !

@kwent
Copy link

kwent commented Nov 5, 2020

@gmq @rjherrera Thanks for the amazing work! Looks like it's very close to the finish line. How can we help ? Regards

@dkniffin
Copy link
Contributor

dkniffin commented Nov 9, 2020

@gmq Great work on this! I'd love to start using it. What are we waiting on to merge? A review from @hidalgoegz ?

@gmq
Copy link
Contributor Author

gmq commented Dec 9, 2020

We're ready to merge to master!

We'd appreciate any bug reports or other feedback about this so if you'd like to test it before we make a new release, please add the following to your Gemfile:

gem 'activeadmin_addons', git: 'https://github.com/platanus/activeadmin_addons'

@gmq gmq merged commit db8ee13 into master Dec 9, 2020
@gmq gmq deleted the webpacker branch December 9, 2020 14:29
@agrobbin
Copy link

agrobbin commented Dec 14, 2020

@gmq this is great! Out of curiosity, are there also plans to remove the hard runtime dependency on sassc and sassc-rails from the gemspec? Active Admin just did that as well.

blackjid referenced this pull request in platanus/active_material Jan 28, 2021
@djalmaaraujo
Copy link

@gmq I can't make it work on activeadmin latest version. Just says activeadmin_addons/all cannot be found. yarn was added, etc. Javascript file is imported but SCSS does not work even with sass-rails on the gemfile.

@jasonperrone
Copy link

I'm concerned about the comment on this change "if ActiveAdmin was installed in that mode". What about the situation where ActiveAdmin was not installed in that mode, but was later changed to use webpacker?

@matiasgarcia
Copy link

Same as @djalmaaraujo I can't make it work.

Node module is:

Screenshot from 2021-03-08 11-46-36

I tried doing @import "activeadmin_addons" instead of @import "activeadmin_addons/all" and now I get this error:

ERROR in ./app/javascript/stylesheets/active_admin.scss (./node_modules/css-loader/dist/cjs.js??ref--6-1!./node_modules/postcss-loader/src??ref--6-2!./node_modules/sass-loader/dist/cjs.js??ref--6-3!./app/javascript/stylesheets/active_admin.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Invalid CSS after "i": expected 1 selector or at-rule, was "import 'select2';"
        on line 1 of node_modules/activeadmin_addons/src/all.js
        from line 13 of /home/mgarcia/projects/withdrawals/app/javascript/stylesheets/active_admin.scss
>> import 'select2';

Which fails in the first line of all.scss that does:

@import 'select2';

@gmq
Copy link
Contributor Author

gmq commented Mar 12, 2021

@gmq I can't make it work on activeadmin latest version. Just says activeadmin_addons/all cannot be found. yarn was added, etc. Javascript file is imported but SCSS does not work even with sass-rails on the gemfile.

Same as @djalmaaraujo I can't make it work.

I just merged a fix by @ParamagicDev for the documentation. The proper way to import the scss is to use @import 'activeadmin_addons/src/stylesheets/all';

I'm concerned about the comment on this change "if ActiveAdmin was installed in that mode". What about the situation where ActiveAdmin was not installed in that mode, but was later changed to use webpacker?

It checks config.use_webpacker in the Active Admin initializer so the addons generator should make the appropriate changes as long as it's enabled there.

@rjherrera rjherrera mentioned this pull request May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.