Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

Commit

Permalink
Add unminified option
Browse files Browse the repository at this point in the history
  • Loading branch information
Petter Walbø Johnsgård committed Sep 18, 2018
1 parent 2df2417 commit ccd0703
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/heisenberg-scripts/config/webpack.config.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const fs = require( 'fs' );
const ManifestPlugin = require( 'webpack-manifest-plugin' );
const StyleLintPlugin = require( 'stylelint-webpack-plugin' );
const UglifyJsPlugin = require( 'uglifyjs-webpack-plugin' );
const UnminifiedWebpackPlugin = require( 'unminified-webpack-plugin' );
const webpack = require( 'webpack' );

/**
Expand All @@ -29,6 +30,7 @@ const env = getClientEnvironment();
const argv = process.argv.slice( 2 );
const cacheBusting = 0 > argv.indexOf( '--no-filename-hashes' );
const watchFiles = -1 !== argv.indexOf( '--watch' );
const createUnminifed = -1 !== argv.indexOf( '--create-unminified' );

// Assert this just to be safe.
if ( watchFiles && '"development"' !== env['process.env'].NODE_ENV ) {
Expand Down Expand Up @@ -200,6 +202,14 @@ module.exports = ( options ) => {
},
})
);

if ( createUnminifed ) {
config.plugins.push(
new UnminifiedWebpackPlugin( {
postfix: 'unminified',
} )
);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/heisenberg-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"stylelint-webpack-plugin": "0.10.5",
"svgo": "1.0.5",
"uglifyjs-webpack-plugin": "1.2.5",
"unminified-webpack-plugin": "1.4.2",
"validator": "10.3.0",
"webpack": "3.12.0",
"webpack-dev-server": "2.11.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function printFileSizesAfterBuild( webpackStats, previousSizeMap, dest ) {

const longestChunkLabelLength = Math.max.apply(
null,
assets.map( asset => stripAnsi( asset.chunkNames[0] ).length )
assets.map( asset => asset.chunkNames[0] ? stripAnsi( asset.chunkNames[0] ).length : 0 )
);

const sortedAssets = _.orderBy( assets, [ asset => asset.folder + path.sep + asset.name.toLowerCase() ], [ 'asc' ] );
Expand All @@ -88,7 +88,7 @@ function printFileSizesAfterBuild( webpackStats, previousSizeMap, dest ) {
prevFiletype = asset.folder;
}

let chunkLabel = asset.chunkNames[0];
let chunkLabel = asset.chunkNames[0] || '';
const chunkLength = stripAnsi( chunkLabel ).length;

if ( chunkLength < longestChunkLabelLength ) {
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9737,6 +9737,10 @@ universalify@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"

unminified-webpack-plugin@1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/unminified-webpack-plugin/-/unminified-webpack-plugin-1.4.2.tgz#2cf5294abe7827bb874354e30ee3e0c5ae0e8743"

unpipe@1.0.0, unpipe@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec"
Expand Down

0 comments on commit ccd0703

Please sign in to comment.