Skip to content

Commit

Permalink
⭐ new: created localized builds
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed May 30, 2016
1 parent 532db27 commit 102d38f
Show file tree
Hide file tree
Showing 26 changed files with 79,315 additions and 6 deletions.
76 changes: 73 additions & 3 deletions config/webpack.build.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
var webpack = require("webpack");
var path = require("path");
var del = require("del");
var fs = require("fs");
var glob = require("glob");

var merge = require("webpack-merge");
var wpBaseConfig = require("./webpack.base.config");



module.exports = [
wpBaseConfig,
merge(wpBaseConfig, {
Expand All @@ -21,7 +25,7 @@ module.exports = [
}
})
]
}),
})/*,
merge(wpBaseConfig, {
entry: path.resolve('lib', 'locales', 'locale-build.js'),
output: {
Expand All @@ -30,7 +34,73 @@ module.exports = [
library: "Fakerator",
libraryTarget: "umd"
}
})
})*/
];

del.sync(["./dist"]);
del.sync(["./dist/**"]);


(function() {
var localeDirs = glob.sync("./lib/locales/*/");

//console.log("asd", localeDirs);

var wrapper = fs.readFileSync(path.join(".", "lib", "locales", "locale-build.js")).toString();

localeDirs.forEach(function(dir) {

if (fs.existsSync(path.join(dir, "index.js"))) {
//var locale = require(path.join("..", dir, "index"));
var localeID = dir.split("/")[3];
var fallbackID = "default";

//console.log(localeID);
var fName = path.join(dir, "build-tmp.js");

var content = wrapper.replace("%%LOCALEID%%", localeID).replace("%%FALLBACKID%%", fallbackID);

fs.writeFileSync(fName, content);
}
});

})();

var buildFiles = glob.sync("./lib/locales/**/build-tmp.js");

//console.log(buildFiles);

buildFiles.forEach(function(localeFile) {

var localeID = localeFile.split("/")[3];
//console.log(localeFile, localeID);

module.exports.push(merge(wpBaseConfig, {
entry: localeFile,
output: {
path: "./dist/locales",
filename: localeID + ".js",
library: "Fakerator",
libraryTarget: "umd"
}
}));

module.exports.push(merge(wpBaseConfig, {
entry: localeFile,
output: {
path: "./dist/locales",
filename: localeID + ".min.js",
library: "Fakerator",
libraryTarget: "umd"
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
]
}));

});

//del.sync(["./lib/locales/**/build-tmp.js"]);
Loading

0 comments on commit 102d38f

Please sign in to comment.