Parcourir la source

workflow: allow dropping dev only blocks in dev script

Evan You il y a 7 ans
Parent
commit
6dfec3a4ae
2 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 2 1
      rollup.config.js
  2. 3 0
      scripts/dev.js

+ 2 - 1
rollup.config.js

@@ -70,7 +70,8 @@ if (process.env.NODE_ENV === 'production') {
 module.exports = packageConfigs
 module.exports = packageConfigs
 
 
 function createConfig(output, plugins = []) {
 function createConfig(output, plugins = []) {
-  const isProductionBuild = /\.prod\.js$/.test(output.file)
+  const isProductionBuild =
+    process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
   const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
   const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
   const isBunlderESMBuild = /\.esm\.js$/.test(output.file)
   const isBunlderESMBuild = /\.esm\.js$/.test(output.file)
   const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file)
   const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file)

+ 3 - 0
scripts/dev.js

@@ -10,6 +10,9 @@ yarn dev dom
 
 
 # specify the format to output
 # specify the format to output
 yarn dev core --formats cjs
 yarn dev core --formats cjs
+
+# Can also drop all __DEV__ blocks with:
+__DEV__=false yarn dev
 ```
 ```
 */
 */