diff --git a/webpack/clean-temp.js b/webpack/clean-temp.js new file mode 100644 index 00000000..44068281 --- /dev/null +++ b/webpack/clean-temp.js @@ -0,0 +1,17 @@ +var fs = require('fs'); + +var deleteFolderRecursive = function(path) { + if (fs.existsSync(path)) { + fs.readdirSync(path).forEach(function(file,index) { + var curPath = path + "/" + file; + if (fs.lstatSync(curPath).isDirectory()) { // recurse + deleteFolderRecursive(curPath); + } else { // delete file + fs.unlinkSync(curPath); + } + }); + fs.rmdirSync(path); + } +}; + +module.exports = deleteFolderRecursive; diff --git a/webpack/config.js b/webpack/config.js index f9491c3f..74f8bfbb 100644 --- a/webpack/config.js +++ b/webpack/config.js @@ -1,6 +1,9 @@ var path = require('path'); var webpack = require('webpack'); +var cleanTemp = require('./clean-temp.js'); +cleanTemp(path.join(__dirname, '../temp')); + var packageJSON = require('../package.json'); var getBanner = function (compressed) {