Closed sebay00 closed 4 years ago
Hi, as we discussed on Slack, I do now a POC with Razzle to see what happens with a simple component. I'm checking what we can do with the razzle-preset https://www.npmjs.com/package/babel-preset-razzle
No news on this ?
Hi @sebay00 , I found the root cause of this problem.
It’s because the React compiler of Bit has in .babelrc
the flag sourceMaps
set to true, so it’s generating source maps file and causing this issue.
I can think about two solutions:
The first is to find a way in Razzle config to exclude files typed *.js.map
.
The second solution (I tried it and it works) is to fork the compiler and export a new one to your account in bit.dev.
@sebay00 no needs to fork the compiler!
Just add the following configuration to your razzle.config.js
file:
const nodeExternals = require('webpack-node-externals')
module.exports = {
modify: (config, { target, dev }) => {
config.externals =
target === 'node'
? [
nodeExternals({
whitelist: [
dev ? 'webpack/hot/poll?300' : null,
/\.(eot|woff|woff2|ttf|otf)$/,
/\.(svg|png|jpg|jpeg|gif|ico)$/,
/\.(mp4|mp3|ogg|swf|webp)$/,
/\.(css|scss|sass|sss|less)$/,
/^@bit\/(.*)/,
].filter(Boolean),
}),
]
: []
return config
},
}
This is a simple example based on the Razzle repo. I tested it on a few components, and it works.
This issue is solved so I close it.
Description
❓Question
Hello everyone,
I'm trying to associate my component lib (on Bit.dev) with razzle, but I just can't make it work.
I think that I have a problem with my bundler not liking the import like:
Does someone make it work ? And explain me how plz
Specifications
Context and additional information
I'm just trying to add my Button on my project from the Bit lib i created. But can't do it.