transitive-bullshit / create-react-library

CLI for creating reusable react libraries.
https://transitivebullsh.it/javascript-dev-tools-in-2022
4.78k stars 299 forks source link

[request] ability to add babel plugins/edit webpack config. #226

Open r3wt opened 4 years ago

r3wt commented 4 years ago

i would like my development build to maintain the console.log statements, however i would like the production build to have console.log statements stripped. i have did this in several projects using babel-plugin-transform-remove-console, but i can't figure out where to start with this project, called microbundle-crl.i also can't find the github page for the package, as the readme points to the microbundle library it was forked from

JasonHeylon commented 4 years ago

I believe you can just add your own .babelrc in the root of your project folder. And set NODE_ENV=production in 'build' script. Like below

// package.json
"build": "NODE_ENV=production microbundle-crl --no-compress --format modern,cjs",
// .babelrc.js
const plugins = [
  process.env.NODE_ENV === 'production' && 'transform-remove-console',
].filter(Boolean)

module.exports = {
  plugins,
}