Open poltak opened 8 years ago
First off, I'm fairly new to webpack, so not sure if this is something I am doing wrong (probably), however I can't seem to find why.
No you are doing things OK - in fact I ran into this same problem myself while developing reactpub
I think this is as reactpub's entry.js file contains JSX code (as shown in the error message), which cannot be used without being compiled down first by either the JSX or Babel loader. Is that correct?
Yes, that is precisely the reason for this error
I am wondering what I'm doing wrong here and how I should go about requiring this file so I can use reactpub?
Take a look at the webpack config of the following projects:
blog.bguiz.com
is my website that I'm building using reactpub. But it is mostly comprised of the markdown files. The ReactJs code all is contained in reactpub-blog-basic-theme
. It is up to you whether you wish to separate your theme from your content of course.
You cannot avoid using babel on reactpub
or the theme should you choose to create one - as I have not designed for that use case. That does not mean that you need to use babel to transpile all your node_modules
though, in the webpack config, you can configure babel-loader
such that it excludes all of node_modules
except for certain ones - exclude
can be a regular expression.
HTH, Brendan
@poltak Also, realised that my previous explanation of exclude
for babel-loader
may have been a little vague... and I realised that in my theme, I was actually babel-ing my entire node_modules
...
So I fixed that, and the diff is answers your question much more better than my first comment: see exclude
.
HTH (better this time), Brendan
--> Here's the relevant section of webpack documentation for loader exclude
Hi there. First off, I'm fairly new to webpack, so not sure if this is something I am doing wrong (probably), however I can't seem to find why.
I am requiring
reactpub/entry
in my entry.js, using the following line:const reactpubEntry = require('reactpub/entry');
However, I am getting this err output from webpack:
I think this is as reactpub's entry.js file contains JSX code (as shown in the error message), which cannot be used without being compiled down first by either the JSX or Babel loader. Is that correct? I am extending the webpack config returned by
reactpubWebpack()
adding in Babel loader configured with es2015 and react presets, however I am excluding thenode_modules
dir, so I don't have to compile all my deps.So yes, I am wondering what I'm doing wrong here and how I should go about requiring this file so I can use reactpub?