Skip to content

Commit

Permalink
perf(infrastructure): Cut build time in half with opt-in env var (#1128)
Browse files Browse the repository at this point in the history
A new `GENERATE_SOURCE_MAPS=false` env var disables source map generation in dev mode, which cuts build and recompile times in half.

Invoked like so:

```bash
GENERATE_SOURCE_MAPS=false npm run dev
```
  • Loading branch information
acdvorak committed Aug 17, 2017
1 parent 0754628 commit e36639f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const OUT_PATH = path.resolve('./build');
const PUBLIC_PATH = '/assets/';
const IS_DEV = process.env.MDC_ENV === 'development';
const IS_PROD = process.env.MDC_ENV === 'production';
const GENERATE_SOURCE_MAPS =
process.env.MDC_GENERATE_SOURCE_MAPS === 'true' ||
(process.env.MDC_GENERATE_SOURCE_MAPS !== 'false' && IS_DEV);
const DEVTOOL = GENERATE_SOURCE_MAPS ? 'source-map' : false;

const banner = [
'/*!',
Expand All @@ -50,20 +54,20 @@ const CSS_LOADER_CONFIG = [
{
loader: 'css-loader',
options: {
sourceMap: true,
sourceMap: GENERATE_SOURCE_MAPS,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: IS_DEV,
plugins: () =>[require('autoprefixer')({grid: false})],
sourceMap: GENERATE_SOURCE_MAPS,
plugins: () => [require('autoprefixer')({grid: false})],
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
sourceMap: GENERATE_SOURCE_MAPS,
includePaths: glob.sync('packages/*/node_modules').map((d) => path.join(__dirname, d)),
},
},
Expand Down Expand Up @@ -106,7 +110,7 @@ module.exports = [{
devServer: {
disableHostCheck: true,
},
devtool: IS_DEV ? 'source-map' : false,
devtool: DEVTOOL,
module: {
rules: [{
test: /\.js$/,
Expand All @@ -133,7 +137,7 @@ module.exports = [{
devServer: {
disableHostCheck: true,
},
devtool: IS_DEV ? 'source-map' : false,
devtool: DEVTOOL,
module: {
rules: [{
test: /\.js$/,
Expand Down Expand Up @@ -190,7 +194,7 @@ module.exports = [{
devServer: {
disableHostCheck: true,
},
devtool: IS_DEV ? 'source-map' : false,
devtool: DEVTOOL,
module: {
rules: [{
test: /\.scss$/,
Expand Down Expand Up @@ -220,7 +224,7 @@ if (IS_DEV) {
devServer: {
disableHostCheck: true,
},
devtool: 'source-map',
devtool: DEVTOOL,
module: {
rules: [{
test: /\.scss$/,
Expand Down

0 comments on commit e36639f

Please sign in to comment.