aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gruntfile.js7
-rw-r--r--grunt/bs-commonjs-generator.js17
2 files changed, 12 insertions, 12 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index 60262ab87..1262a668a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -438,7 +438,7 @@ module.exports = function (grunt) {
grunt.registerTask('test', testSubtasks);
// JS distribution task.
- grunt.registerTask('dist-js', ['concat', 'uglify:core']);
+ grunt.registerTask('dist-js', ['concat', 'uglify:core', 'commonjs']);
// CSS distribution task.
grunt.registerTask('less-compile', ['less:compileCore', 'less:compileTheme']);
@@ -464,8 +464,9 @@ module.exports = function (grunt) {
});
grunt.registerTask('commonjs', 'Generate CommonJS entrypoint module in dist dir.', function () {
- var files = grunt.config.get('concat.bootstrap.src');
- generateCommonJSModule(grunt, files);
+ var srcFiles = grunt.config.get('concat.bootstrap.src');
+ var destFilepath = 'dist/js/npm.js';
+ generateCommonJSModule(grunt, srcFiles, destFilepath);
});
// Docs task.
diff --git a/grunt/bs-commonjs-generator.js b/grunt/bs-commonjs-generator.js
index 0a76333d9..8ab309b33 100644
--- a/grunt/bs-commonjs-generator.js
+++ b/grunt/bs-commonjs-generator.js
@@ -2,17 +2,16 @@
var fs = require('fs');
var path = require('path');
-var destDir = 'dist/js';
-var destFilename = 'npm.js';
-var destFilepath = path.join(destDir, destFilename);
+module.exports = function generateCommonJSModule(grunt, srcFiles, destFilepath) {
+ var destDir = path.dirname(destFilepath);
-function srcPathToDestRequire(srcFilepath) {
- var requirePath = path.relative(destDir, srcFilepath);
- return "require('"+requirePath+"')";
-}
+ function srcPathToDestRequire(srcFilepath) {
+ var requirePath = path.relative(destDir, srcFilepath);
+ return "require('"+requirePath+"')";
+ }
-module.exports = function generateCommonJSModule(grunt, files) {
- var moduleOutputJs = files.map(srcPathToDestRequire).join('\n');
+ var moduleOutputJs = srcFiles.map(srcPathToDestRequire).join('\n');
+
try {
fs.writeFileSync(destFilepath, moduleOutputJs);
}