diff --git a/tasks/preprocess.js b/tasks/preprocess.js index 302628090ec..8753e7c160b 100644 --- a/tasks/preprocess.js +++ b/tasks/preprocess.js @@ -16,25 +16,32 @@ updateVersion(constants.pathToPlotlyVersion); // convert scss to css to js and static css file function makeBuildCSS() { - sass.render({ - file: constants.pathToSCSS, - outputStyle: 'compressed' - }, function(err, result) { - if(err) throw err; + sass.render( + { + file: constants.pathToSCSS, + outputStyle: 'compressed' + }, + function (err, result) { + if (err) throw err; - // To support application with strict CSP where styles cannot be inlined, - // build a static CSS file that can be included into such applications. - var staticCSS = String(result.css); - for(var k in mapBoxGLStyleRules) { - staticCSS = addAdditionalCSSRules(staticCSS, '.js-plotly-plot .plotly .mapboxgl-' + k, mapBoxGLStyleRules[k]); - } - fs.writeFile(constants.pathToCSSDist, staticCSS, function(err) { - if(err) throw err; - }); + // To support application with strict CSP where styles cannot be inlined, + // build a static CSS file that can be included into such applications. + var staticCSS = String(result.css); + for (var k in mapBoxGLStyleRules) { + staticCSS = addAdditionalCSSRules( + staticCSS, + '.js-plotly-plot .plotly .mapboxgl-' + k, + mapBoxGLStyleRules[k] + ); + } + fs.writeFile(constants.pathToCSSDist, staticCSS, function (err) { + if (err) throw err; + }); - // css to js to be inlined - pullCSS(String(result.css), constants.pathToCSSBuild); - }); + // css to js to be inlined + pullCSS(String(result.css), constants.pathToCSSBuild); + } + ); } function addAdditionalCSSRules(staticStyleString, selector, style) { @@ -44,7 +51,7 @@ function addAdditionalCSSRules(staticStyleString, selector, style) { function exposePartsInLib() { var obj = {}; - var insert = function(name, folder) { + var insert = function (name, folder) { obj[name] = folder + '/' + name; }; @@ -52,7 +59,7 @@ function exposePartsInLib() { insert('calendars', 'src/components'); - constants.allTraces.forEach(function(k) { + constants.allTraces.forEach(function (k) { insert(k, 'src/traces'); }); @@ -60,24 +67,23 @@ function exposePartsInLib() { } function writeLibFiles(obj) { - for(var name in obj) { + for (var name in obj) { common.writeFile( path.join(constants.pathToLib, name + '.js'), - [ - '\'use strict\';', - '', - 'module.exports = require(\'../' + obj[name] + '\');', - '' - ].join('\n') + ["'use strict';", '', "module.exports = require('../" + obj[name] + "');", ''].join('\n') ); } } function copyTopojsonFiles() { + const FILES_TO_EXCLUDE = ['country_names_iso_codes.json']; fs.copy( constants.pathToTopojsonSrc, constants.pathToTopojsonDist, - { clobber: true }, + { + clobber: true, + filter: (filePath) => !FILES_TO_EXCLUDE.includes(path.basename(filePath)) + }, common.throwOnError ); }