diff --git a/gulp/sass.js b/gulp/sass.js index 0e44db99b5..e892cb17ae 100644 --- a/gulp/sass.js +++ b/gulp/sass.js @@ -8,6 +8,8 @@ const postcssCopyAssets = require("postcss-copy-assets"); const postcssImport = require("postcss-import"); const postcssUrl = require("postcss-url"); +const PROD_MODE = process.env.NODE_ENV === "production"; + module.exports = (gulp, plugins, blueprint) => { const path = require("path"); const COPYRIGHT_HEADER = require("./util/text").COPYRIGHT_HEADER; @@ -53,6 +55,7 @@ module.exports = (gulp, plugins, blueprint) => { const postcssOptions = { to : blueprint.destPath(project, "dist.css"), + map: { inline: !PROD_MODE }, }; const postcssPlugins = [ // inline all imports @@ -73,13 +76,13 @@ module.exports = (gulp, plugins, blueprint) => { ]; return gulp.src(config.srcGlob(project, true)) - .pipe(plugins.sourcemaps.init()) + .pipe(PROD_MODE ? plugins.util.noop() : plugins.sourcemaps.init()) .pipe(sassCompiler) .pipe(plugins.postcss(postcssPlugins, postcssOptions)) .pipe(plugins.stripCssComments({ preserve: /^\*/ })) .pipe(plugins.replace(/\n{3,}/g, "\n\n")) // see https://github.com/floridoo/vinyl-sourcemaps-apply/issues/11#issuecomment-231220574 - .pipe(plugins.sourcemaps.write(undefined, { sourceRoot: null })) + .pipe(PROD_MODE ? plugins.util.noop() : plugins.sourcemaps.write(undefined, { sourceRoot: null })) .pipe(blueprint.dest(project)) .pipe(plugins.connect.reload()); }); diff --git a/gulp/util/webpack-config.js b/gulp/util/webpack-config.js index 67549d7e0c..f6859a072c 100644 --- a/gulp/util/webpack-config.js +++ b/gulp/util/webpack-config.js @@ -9,10 +9,11 @@ const camelCase = require("lodash/camelCase"); const upperFirst = require("lodash/upperFirst"); const webpack = require("webpack"); +const PROD_MODE = process.env.NODE_ENV === "production"; const globalName = (id) => upperFirst(camelCase(id)); const DEFAULT_CONFIG = { - devtool: "source-map", + devtool: PROD_MODE ? undefined : "source-map", resolve: { extensions: ["", ".js"] }, plugins: [ new webpack.DefinePlugin({ @@ -25,7 +26,7 @@ const DEFAULT_CONFIG = { // Default webpack config options with support for TypeScript files const TYPESCRIPT_CONFIG = { - devtool: "source-map", + devtool: PROD_MODE ? undefined : "source-map", resolve: { extensions: ["", ".js", ".ts", ".tsx"] }, ts: { // do not emit declarations since we are bundling diff --git a/package.json b/package.json index 9553e3b0de..6053ffb63a 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "scripts": { "bootstrap": "lerna bootstrap", "build:landing": "(cd packages/landing; npm run build)", - "build:gulp": "NODE_ENV='\"production\"' gulp build", - "build:site": "npm-run-all build:gulp build:landing copy:docs copy:landing", - "copy:docs": "cp -r packages/docs/dist docs/docs", - "copy:landing": "cp -r packages/landing/dist/* docs/.", + "build:gulp": "NODE_ENV='production' gulp build", + "build:site": "npm-run-all build:gulp build:landing clean:docs copy:docs copy:landing", + "clean:docs": "rm -rf docs && git checkout docs/CNAME", + "copy:docs": "cp -rf packages/docs/dist docs/docs", + "copy:landing": "cp -rf packages/landing/dist/* docs/.", "serve": "http-server docs" }, "dependencies": {