浏览代码

add postcustom

famanoder 7 年之前
父节点
当前提交
ad03f3d140
共有 3 个文件被更改,包括 27 次插入12 次删除
  1. 3 2
      package.json
  2. 17 7
      scripts/customBuild.js
  3. 7 3
      scripts/rmDist.js

+ 3 - 2
package.json

@@ -28,11 +28,12 @@
     "url": "https://github.com/jdf2e/nutui.git"
   },
   "scripts": {
-    "clean": "node scripts/rmDist",
+    "clean": "node scripts/rmDist dist",
     "dev": "npm run clean && webpack-dev-server -d --open --progress",
     "build": "npm run clean && cross-env NODE_ENV=production webpack --hide-modules --progress",
     "add": "node scripts/addComponent",
-    "custom": "node scripts/customBuild && npm run clean && cross-env NODE_ENV=production webpack --config webpack.config.custom.js --hide-modules --progress && rm -rf custom.json && rm -rf src/nutui-custom.js"
+    "custom": "node scripts/customBuild && npm run clean && cross-env NODE_ENV=production webpack --config webpack.config.custom.js --hide-modules --progress",
+    "postcustom": "node scripts/rmDist custom.json src/nutui-custom.js"
   },
   "dependencies": {
     "babel-runtime": "^6.26.0",

+ 17 - 7
scripts/customBuild.js

@@ -34,15 +34,25 @@ inquirer
                 }
             });
         });
-        fs.readFile(path.join(__dirname, './customBuildTpl.js'), 'utf8', function (err, data) {
-          fs.writeFile(path.join(__dirname, '../src/nutui-custom.js'), str + data, (err) => {
-            if (err) throw err;
-            console.log(`生成nutui-custom.js文件成功`);
-          });
-        });
 
         fs.writeFile(destPath, JSON.stringify(choices, null, 2), (err) => {
             if (err) throw err;
             console.log(`生成配置文件custom.json成功`);
+
+            fs.readFile(path.join(__dirname, './customBuildTpl.js'), 'utf8', function (err, data) {
+              fs.writeFile(path.join(__dirname, '../src/nutui-custom.js'), str + data, (err) => {
+                if (err) throw err;
+                console.log(`生成nutui-custom.js文件成功`);
+    
+                console.log([
+                  '', 
+                  'if there are some errors about "JavaScript heap out of memory",', 
+                  'you can have a read about "https://www.npmjs.com/package/increase-memory-limit"',
+                  ''
+                ].join('\n'));
+              });
+            });
         });
-  });
+        
+  });
+  

+ 7 - 3
scripts/rmDist.js

@@ -1,5 +1,9 @@
 const rimraf = require('rimraf');
 
-rimraf('dist',function(err){
-    console.log('rimraf:'+(err||'success'));
-});
+let files = process.argv.slice(2);
+
+files.length && files.forEach(function(file) {
+    rimraf.sync(file);
+    console.log('rm '+file+' success!');
+});
+