mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-14 02:24:00 +01:00
4a5c7f21d5
* switch to grunt-postcss and autoprefixer directly; this is the recommended way. * uglify: specify `ie8` for compatibility * specify `cascade:false` for autoprefixer * specify `ieCompat` for less * drop grunt-contrib-compress since it doesn't work with Node.js 10.x * remove grunt-contrib-htmlmin to match the v4 docs * clean up Gruntfile.js * clean up .travis.yml and backport changes from v4 * build ie10-viewport-bug-workaround.less since it's used in examples * move shrinkwrap to root * bs-commonjs-generator.js: Use `path.posix` * remove .hound.yml * remove references to no longer used PR bots * backport and adapt the sri generation script from v4
31 lines
978 B
JavaScript
31 lines
978 B
JavaScript
/*!
|
|
* Bootstrap Grunt task for the CommonJS module generation
|
|
* https://getbootstrap.com/
|
|
* Copyright 2014-2018 Twitter, Inc.
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
var COMMONJS_BANNER = '// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.\n';
|
|
|
|
module.exports = function generateCommonJSModule(grunt, srcFiles, destFilepath) {
|
|
var destDir = path.dirname(destFilepath);
|
|
|
|
function srcPathToDestRequire(srcFilepath) {
|
|
var requirePath = path.posix.relative(destDir, srcFilepath);
|
|
return 'require(\'' + requirePath + '\')';
|
|
}
|
|
|
|
var moduleOutputJs = COMMONJS_BANNER + srcFiles.map(srcPathToDestRequire).join('\n');
|
|
try {
|
|
fs.writeFileSync(destFilepath, moduleOutputJs);
|
|
} catch (err) {
|
|
grunt.fail.warn(err);
|
|
}
|
|
grunt.log.writeln('File ' + destFilepath.cyan + ' created.');
|
|
};
|