{"id":919,"date":"2019-03-11T23:53:38","date_gmt":"2019-03-11T15:53:38","guid":{"rendered":"https:\/\/www.bluesdream.com\/blog\/?p=919"},"modified":"2019-03-12T09:58:11","modified_gmt":"2019-03-12T01:58:11","slug":"gulp4-frontend-automation-workflow-config","status":"publish","type":"post","link":"https:\/\/www.bluesdream.com\/blog\/gulp4-frontend-automation-workflow-config.html","title":{"rendered":"Gulp4 \u524d\u7aef\u81ea\u52a8\u5316\u5de5\u4f5c\u6d41\u914d\u7f6e"},"content":{"rendered":"<p>\u968f\u7740\u6700\u8fd1\u628a nodejs \u4ece <code>8.x<\/code> \u5347\u7ea7\u5230\u4e86 <code>10.x<\/code>\uff0c\u53d1\u73b0 <code>Gulp3.x<\/code> \u65e9\u5df2\u7ecf\u4e0d\u80fd\u517c\u5bb9\u65b0\u7248\u7684 node\uff0c\u5e76\u4e14\u73af\u5883\u4e2d\u7684\u90e8\u5206\u4f9d\u8d56\uff0c\u4e5f\u5df2\u7ecf\u88ab\u6dd8\u6c70\u3002<br \/>\n\u4e8e\u662f\u8d81\u6b64\u673a\u4f1a\uff0c\u628a Gulp \u5347\u7ea7\u4e3a <code>4.x<\/code> \u7248\u672c\uff0c\u5e76\u628a\u6574\u4e2a\u73af\u5883\u91cd\u65b0\u6539\u9020\u4e86\u4e00\u4e0b\u3002<\/p>\n<p>\u73b0\u5df2\u7ecf\u53d1\u5e03\u81f3 Github \u548c NPM \u4f5c\u4e3a\u4e0d\u5b9a\u671f\u7ef4\u62a4\u7684\u4e00\u4e2a\u9879\u76ee\u3002\u5173\u4e8e\u540e\u7eed\u66f4\u65b0\u548c\u7ef4\u62a4\u60c5\u51b5\uff0c\u8bf7\u5173\u6ce8\u672c\u9879\u76ee\u7684\uff1a<a href=\"https:\/\/github.com\/zhonglimh\/Ublue-gulp-config\">GitHub<\/a> \u548c <a href=\"https:\/\/www.npmjs.com\/package\/ublue-gulp-config\">NPM<\/a> \u3002<\/p>\n<p>\u5982\u679c\u4f60\u521a\u63a5\u89e6 Gulp\uff0c\u53ef\u4ee5\u67e5\u770b\u6211\u4ee5\u524d\u5199\u7684\u6587\u7ae0 <a href=\"https:\/\/github.com\/zhonglimh\/Gulp\">Gulp\u6784\u5efa\u524d\u7aef\u81ea\u52a8\u5316\u5de5\u4f5c\u6d41\uff08Gulp\u5165\u95e8\u4ecb\u7ecd\uff09<\/a>\u3002<br \/>\n<!--more--><\/p>\n<h2>\u7b80\u4ecb(Introduction)<\/h2>\n<p>\u7b80\u5355\u5b9e\u7528\u7684\u524d\u7aef\u81ea\u52a8\u5316\u5de5\u4f5c\u6d41\u914d\u7f6e\uff0c\u57fa\u4e8e Gulp4.x<br \/>\nSimple and practical front-end automated workflow configuration based on Gulp4.x<\/p>\n<h2>\u7279\u6027(Features)<\/h2>\n<ul>\n<li>SASS (CSS preprocessor)<\/li>\n<li>\u56fe\u50cf\u538b\u7f29\u548c\u8f6cBase64 (Images compress &amp; save base64 image)<\/li>\n<li>JS\u538b\u7f29 (JavaScript compressor)<\/li>\n<li>\u70ed\u52a0\u8f7d (Hot reload)<\/li>\n<li>\u4e00\u5957\u73af\u5883\u591a\u9879\u76ee\u5171\u5b58 (Multi-Project Builds)<\/li>\n<\/ul>\n<h2>\u76ee\u5f55\u7ed3\u6784(Directory structure)<\/h2>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n+ project_file_name                 \/\/ Project folder(Example)\n    + Build                         \/\/ Production folder(Output floder)\n        - etc...\n    + dist                          \/\/ Pevelopment folder(Output floder)\n        - etc...\n    + dist__test                    \/\/ Test folder(Output floder)\n        - etc...\n    + src                           \/\/ Source code\n        - images                    \/\/ Image folder\n        - js                        \/\/ Script folder\n        - lib                       \/\/ CSS\/JS library\n        - scss                      \/\/ Style folder\n        - project.config.js         \/\/ Project custom config\n- .gitignore                        \/\/ Exclude files from git\n- gulp.config.js                    \/\/ Gulp custom config\n- gulpfile.js                       \/\/ Gulp config\n- package.json                      \/\/ Dependency &amp; Module list\n- README.md                         \/\/ Documentation\n- yarn.lock                         \/\/ Yarn\n<\/pre>\n<h2>\u73af\u5883\u8981\u6c42(Pre Required)<\/h2>\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u5168\u5c40\u5b89\u88c5\u4e86 gulp \u8bf7\u5148\u5220\u9664\u65e7\u7248\u672c\u540e\u518d\u5b89\u88c5<br \/>\nIf you've previously installed gulp globally, please remove the old version<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ npm rm --global gulp\n# or\n$ yarn global remove gulp\n<\/pre>\n<p>\u5168\u5c40\u5b89\u88c5 gulp-cli<br \/>\nInstall the gulp command line utility<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ npm install --global gulp-cli\n# or\n$ yarn global add gulp-cli\n<\/pre>\n<h2>\u5b89\u88c5\u65b9\u5f0f(Installation)<\/h2>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# \u5b89\u88c5 - Using npm or yarn\n$ npm i ublue-gulp-config\n# or\n$ yarn add ublue-gulp-config\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# \u5b89\u88c5\u4f9d\u8d56 - Install dependency\n$ npm install\n# or\n$ yarn install\n<\/pre>\n<h2>\u4f7f\u7528\u65b9\u6cd5(Used)<\/h2>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# \u9879\u76ee\u521d\u59cb\u5316 - Project initialization\n$ gulp init\n\n# \u73af\u5883\u542f\u52a8 - Start it\n$ gulp\n<\/pre>\n<h2>\u73af\u5883\u5207\u6362(Using environment variables)<\/h2>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# \u53d1\u5e03\u6d4b\u8bd5\u73af\u5883 - Build for test environment\n$ gulp init --test\n\n# \u53d1\u5e03\u751f\u4ea7\u73af\u5883 - Build for production environment\n$ gulp init --build\n\n# \u6e05\u7406\u751f\u4ea7\u76ee\u5f55 - Clean up development or production\n$ gulp clean\n\n# \u6e05\u7406\u6307\u5b9a\u73af\u5883\u76ee\u5f55 - Clean up the specified environment directory\n$ gulp clean --test\n<\/pre>\n<h2>\u5f00\u6e90\u8bb8\u53ef(License)<\/h2>\n<p><a href=\"https:\/\/opensource.org\/licenses\/MIT\">MIT<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u968f\u7740\u6700\u8fd1\u628a nodejs \u4ece 8.x \u5347\u7ea7\u5230\u4e86 10.x\uff0c\u53d1\u73b0 Gulp3.x \u65e9\u5df2\u7ecf\u4e0d\u80fd\u517c\u5bb9\u65b0\u7248\u7684 node\uff0c\u5e76\u4e14\u73af\u5883\u4e2d\u7684\u90e8\u5206\u4f9d\u8d56\uff0c\u4e5f\u5df2\u7ecf\u88ab\u6dd8\u6c70\u3002 \u4e8e\u662f\u8d81\u6b64\u673a\u4f1a\uff0c\u628a Gulp \u5347\u7ea7\u4e3a 4.x \u7248\u672c\uff0c\u5e76\u628a\u6574\u4e2a\u73af\u5883\u91cd\u65b0\u6539\u9020\u4e86\u4e00\u4e0b\u3002 \u73b0\u5df2\u7ecf\u53d1\u5e03\u81f3 Github \u548c NPM \u4f5c\u4e3a\u4e0d\u5b9a\u671f\u7ef4\u62a4\u7684\u4e00\u4e2a\u9879\u76ee\u3002\u5173\u4e8e\u540e\u7eed\u66f4\u65b0\u548c\u7ef4\u62a4\u60c5\u51b5\uff0c\u8bf7\u5173\u6ce8\u672c\u9879\u76ee\u7684\uff1aGitHub \u548c NPM \u3002 \u5982\u679c\u4f60\u521a\u63a5\u89e6 Gulp\uff0c\u53ef\u4ee5\u67e5\u770b\u6211\u4ee5\u524d\u5199\u7684\u6587\u7ae0 Gulp\u6784\u5efa\u524d\u7aef\u81ea\u52a8\u5316\u5de5\u4f5c\u6d41\uff08Gulp\u5165\u95e8\u4ecb\u7ecd\uff09\u3002<\/p>\n","protected":false},"author":1,"featured_media":921,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[129,179,180],"class_list":["post-919","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-front-end","tag-gulp","tag-gulp4","tag-npm"],"_links":{"self":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/919"}],"collection":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":0,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/posts\/919\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media\/921"}],"wp:attachment":[{"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/categories?post=919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bluesdream.com\/blog\/wp-json\/wp\/v2\/tags?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}