Skip to content

path to resource in node_modules folder #347

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

Closed
krazyjakee opened this issue May 8, 2017 · 5 comments
Closed

path to resource in node_modules folder #347

krazyjakee opened this issue May 8, 2017 · 5 comments

Comments

@krazyjakee
Copy link

How do I something like:
asset_pack_path("bootstrap/dist/bootstrap.css")

where the bootstrap folder is in the node_modules folder?

@gauravtiwari
Copy link
Member

@krazyjakee You can't do that with Webpacker. One way is to link that file within the main pack bundle like so,

// packs/application.js
import 'bootstrap/dist/bootstrap.css'

or you could do it with common chunk - https://webpack.js.org/plugins/commons-chunk-plugin/

@krazyjakee
Copy link
Author

Using

import "react-rails-ujs/dist/react-rails-ujs.js"

I get

ERROR in ./~/react-rails-ujs/dist/react-rails-ujs.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "/Users/*/WebApp/node_modules/react-rails-ujs"

@gauravtiwari
Copy link
Member

You would need to install es2015 preset yarn add babel-preset-es2015

@krazyjakee
Copy link
Author

Thanks, that fixes the compilation issue but rails just gives me "Can't find react-rails-ujs/dist/react-rails-ujs.js".

@krazyjakee
Copy link
Author

My mistake that was calling from elsewhere. Thanks!

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

No branches or pull requests

2 participants