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

Workaround for custom webpack providers? #443

Closed
scwood opened this issue Aug 15, 2016 · 6 comments
Closed

Workaround for custom webpack providers? #443

scwood opened this issue Aug 15, 2016 · 6 comments

Comments

@scwood
Copy link

scwood commented Aug 15, 2016

I'm afraid that the answer for this will just be "eject" but I'll ask anyways.

With an entry point like this:

// index.js
import 'jquery/dist/jquery.min.js';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/js/bootstrap.min.js';

You'll get the error:

screen shot 2016-08-14 at 7 54 30 pm

For right now I have jQuery in my index.html, but believe this is fixed by providing something like the following in the webpack config:

  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    })
  ],

However I'd really like to avoid ejecting. Any thoughts?

@mxstbr
Copy link
Contributor

mxstbr commented Aug 15, 2016

For right now I have jQuery in my index.html

Is it working? Why would the webpack setup be beneficial?

@scwood
Copy link
Author

scwood commented Aug 15, 2016

Yeah placing a script tag in my html works fine. As for why the webpack setup would be beneficial I suppose mostly just for convenience. All the 'static' dependencies can be listed at the top of your entry point and the index.html can remain clean.

@eanplatter
Copy link
Contributor

Yeah I believe the current API calls for just using the index.html file for these kinds of things.

Might not be relevant to your use case, but it might make sense to use something like react-bootstrap which covers features like dropdowns without the use of jQuery as jQuery can be tricky to use with React.

@kasperpeulen
Copy link
Contributor

Yeah, I was wondering, do you only use jquery for bootstrap? I think using react-bootstrap makes much more sense in this setup.

@swamikevala
Copy link

I also need this because I want to use datatables (which is a jquery plugin). A little tricky to use with react - but I cannot find anything as good as this which is written in react (esp responsive features)

btw - I love this project. Has saved me days and days... thanks so much!

@gaearon
Copy link
Contributor

gaearon commented Aug 29, 2016

If you want to avoid ejection, the best you can do is to create your own package that combines jquery with bootstrap and uses webpack to build them together with whatever configuration you need. You can then put this package on npm and use it from CRA project.

@gaearon gaearon closed this as completed Sep 2, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants