{"_id":"@diamondyuan/gulp-ifdef","name":"@diamondyuan/gulp-ifdef","dist-tags":{"latest":"0.3.0"},"versions":{"0.3.0":{"name":"@diamondyuan/gulp-ifdef","version":"0.3.0","description":"Streaming conditional compilation middleware for gulp.","main":"index.js","publishConfig":{"access":"public"},"scripts":{"test":"jasmine"},"repository":{"type":"git","url":"git+https://github.com/yuxiaomin/gulp-ifdef.git"},"keywords":["gulpplugin","ifdef"],"author":{"name":"Xiaomin YU","url":"yuxiaomin@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/yuxiaomin/gulp-ifdef/issues"},"homepage":"https://github.com/yuxiaomin/gulp-ifdef#readme","dependencies":{"source-map":"^0.7.3","through2":"^3.0.1","vinyl-sourcemaps-apply":"^0.2.1"},"engines":{"node":">= 6.0.0"},"devDependencies":{"gulp":"^4.0.2","gulp-sourcemaps":"^2.6.5","jasmine":"^3.5.0"},"_id":"@diamondyuan/gulp-ifdef@0.3.0","gitHead":"42400f06953d5e9a0c34178ff4cdf63e389fe148","_nodeVersion":"18.17.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-jN7OZdszECLXlcjSNt4mtehnpDwxoy0SoD+3JPT3Rz70VCpjIzkQJSslcRvmExTyo7j6jyS7Hl+qq6P2YCdGjQ==","shasum":"cea40067ff0e6b26a265559f82f4f70dfc79c248","tarball":"https://registry.npmjs.org/@diamondyuan/gulp-ifdef/-/gulp-ifdef-0.3.0.tgz","fileCount":22,"unpackedSize":21949,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCgeivh7CWKFk2uDvxNMZ9Bh0ucjGIzShK8RAw9V1mTmwIgCtsRyexb5+Q9oHzINJFrF5zya2C/isT+fIZv4AXKKBs="}]},"_npmUser":{"name":"diamondyuan","email":"541832074@qq.com"},"directories":{},"maintainers":[{"name":"diamondyuan","email":"541832074@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gulp-ifdef_0.3.0_1695263269211_0.581431372083465"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-21T02:27:49.101Z","0.3.0":"2023-09-21T02:27:49.412Z","modified":"2023-09-21T02:27:49.722Z"},"maintainers":[{"name":"diamondyuan","email":"541832074@qq.com"}],"description":"Streaming conditional compilation middleware for gulp.","homepage":"https://github.com/yuxiaomin/gulp-ifdef#readme","keywords":["gulpplugin","ifdef"],"repository":{"type":"git","url":"git+https://github.com/yuxiaomin/gulp-ifdef.git"},"author":{"name":"Xiaomin YU","url":"yuxiaomin@gmail.com"},"bugs":{"url":"https://github.com/yuxiaomin/gulp-ifdef/issues"},"license":"MIT","readme":"\nInspired by [nino-porcino](https://github.com/nippur72)'s [ifdev-loader](https://github.com/nippur72/ifdef-loader).\ngulp-ifdef can process not only js/ts files but also html/less files.\n\n## Installation\n\nInstall package with NPM and add it to your development dependencies:\n\n`npm install --save-dev gulp-ifdef`\n\n## Information\n\n<table>\n<tr>\n<td>Package</td><td>gulp-ifdef</td>\n</tr>\n<tr>\n<td>Description</td>\n<td>Conditional compilation</td>\n</tr>\n<tr>\n<td>Node Version</td>\n<td>>= 6.0.0</td>\n</tr>\n</table>\n\n## Usage\n\ngulp-ifdef can delete the source code conditionally according to the condition value in JSON.\n\nLet's say you have below js and html code in src folder\n\nindex.js\n```js\ndoSomething()\n/// #if DEBUG\noutputLog()\n\nfunction outputLog() {\n    // print the debug log to console\n}\n/// #endif\n\n/// #if version < 2\nprintVersionWarning();\n/// #else\ngoodToGo();\n/// #endif\ndoSomethingElse();\n```\n\nindex.html\n```html\n<div>\n    <!-- #if DEBUG -->\n    <div>\n        The following is log list\n    </div>\n    <!-- #endif -->\n</div>\n```\n\nSo in you gulpfile\n\n```js\nvar ifdef = require('gulp-ifdef');\n\ngulp.task('ifdef-copy', function() {\n  return gulp.src([\n    'src/**/*'\n  ], {cwd: './'})\n  .pipe(ifdef({\n    'DEBUG': true,\n    \"version\": 2\n  }, {\n    extname: ['js', 'html']\n  }))\n  .pipe(gulp.dest('./dist'));\n}\n```\n\nThis will conditionally compile the source according to a JSON condition and the ext file name list(this is optinal. if not present then all the files will be processed)\n\nThe above index.js and index.html file in the dist folder will change to the following\n\nindex.js\n```js\ndoSomething()\n\n\n\ngoodToGo();\n\ndoSomethingElse();\n```\n\nindex.html\n```html\n<div>\n\n</div>\n```\n\nThe files type that are not declared in \"extname\" will be kept same in the stream.\n\nNow the supported condition syntax is ```///``` (in js/ts/less) or ```<!-- -->``` (in html) ","readmeFilename":"README.md"}