Ask A Question

Notifications

You’re not receiving notifications from this thread.

Modern Webpack template on Rails 5.1

Jiri Prochazka asked in Rails

I have downloaded this Adminator template, which is modern npm/yarn Webpack theme. As stated in the template's homepage, install instructions are:

> git clone https://github.com/puikinsh/Adminator-admin-dashboard.git adminator
> cd adminator
> npm install
> npm run dev

And it is working like a charm.

Now my question is, how can I implement it to Rails 5.1+? Should I use webpack support when creating a new app:

> rails new myapp --webpack

Template contains a folder assets should that whole folder to app/javascript/pack and run npm install to install node_modules?

But those are not any components, I think it should be rather placed in /vendors folder, right?

Thank you

Reply

Hey Jiri,

I think you're right for the most part. I believe you could just move those assets folders into app/javascript/pack and you'd be able to use reference them from there.

You could probably put it in the vendor folder since you wouldn't really want to edit these files, but that may just require you to import the files into webpacker a bit differently.

You might have to say like import X from '../../vendor/assets/index or whatever. It'll take some experimenting.

I think the vendor folder is the ideal so you aren't tempted to edit any of those files to make updating to newer versions of the template easier. That said, don't let that stop you if you can get it working in app/javascript easier. A running app is more useful than a perfectly organized one. You can always move the files around after you get it working.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.