Skip to content

Commit

Permalink
fix: should not display logs when it's in production mode (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
BuptStEve authored Mar 5, 2019
1 parent 102d0f1 commit 131c98f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tua-api",
"version": "1.0.0",
"version": "1.0.1",
"description": "🏗 A common tool helps converting configs to api functions",
"main": "dist/TuaApi.cjs.js",
"module": "dist/TuaApi.esm.js",
Expand Down
20 changes: 15 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,33 @@ const plugins = [
nodeResolve(),
commonjs(),
babel(),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
]
const env = 'process.env.NODE_ENV'
const external = ['axios', 'fetch-jsonp']

export default [{
input,
output: [ output.cjs, output.esm, output.umd ],
output: [ output.cjs, output.esm ],
plugins,
external,
}, {
input,
output: output.umd,
external,
plugins: [
...plugins,
replace({ [env]: '"development"' }),
],
}, {
input,
output: {
...output.umd,
file: 'dist/TuaApi.umd.min.js',
},
plugins: [ ...plugins, uglify() ],
external,
plugins: [
...plugins,
replace({ [env]: '"production"' }),
uglify(),
],
}]
5 changes: 3 additions & 2 deletions src/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* @param {any} out 具体的输出内容
*/
const logByType = (type) => (...out) => {
/* istanbul ignore else */
if (process.env.NODE_ENV === 'test') return
const env = process.env.NODE_ENV
/* istanbul ignore next */
if (env === 'test' || env === 'production') return

/* istanbul ignore next */
console[type](`[TUA-API]:`, ...out)
Expand Down

0 comments on commit 131c98f

Please sign in to comment.