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

Commit

Permalink
Added an option to disable HTML minification for production builds (c…
Browse files Browse the repository at this point in the history
…loses #68)
  • Loading branch information
dsebastien committed Dec 20, 2015
1 parent 8829148 commit 9adc8af
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
* 0.2.2
* added an option to define whether the production HTML should be minified or not: minifyProductionHTML (true by default)
* Angular 2 does not support HTML minification anymore: https://github.com/dsebastien/modernWebDevBuild/issues/67
* 0.2.1
* minify the production bundle by default
* added the gulp-inline-source plugin (https://www.npmjs.com/package/gulp-inline-source)
* allows to inline resources (scripts, stylesheets, images) within HTML files
* for example very useful for cases where some script can't/musn't be loaded through SystemJS (e.g., zone.js, reflect-metadata, Angular 2 polyfills, ...)
* added an option to define whether the production JS bundle must be minified or not: minifyProductionJSBundle (true by default)
* added an option to define whether the production JS bundle must be mangled or not (true by default)
* added an option to define whether the production JS bundle must be mangled or not: mangleProductionJSBundle (true by default)
* 0.2.0
* BREAKING CHANGE: scripts-javascript-dist now uses core/boot.js as entry point (vs core/core.bootstrap.js in earlier versions) (fixes #
* this new default behavior can be customized by specifying the `distEntryPoint` option (see README or UPGRADE guide)
Expand Down
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ Please make sure to check the file organization section for more background abou
* core: folder containing at least the entrypoint of your application
* commons: folder containing common reusable code (e.g., base utilities)
* services: folder containing generic services (e.g., for local storage)
* core.bootstrap.ts: the entrypoint of your application
* boot.ts: the entrypoint of your application
* app.ts: the application root
* fonts: folder containing fonts of your application (if any)
* images: folder for image assets
* pages: folder for full-blown pages of your application
Expand Down Expand Up @@ -179,6 +180,9 @@ import gulp from "gulp";
import modernWebDevBuild from "modern-web-dev-build";
let options = undefined; // no options are supported yet
//options.minifyHTML = false;
//...
modernWebDevBuild.registerTasks(gulp, options);
```

Expand Down Expand Up @@ -530,15 +534,30 @@ Dev dependencies to add for the above Karma configuration:
### Minimal (application-specific) required file contents
Although we want to limit this list as much as possible, for everything to build successfully, some files need specific contents:

#### core/core.bootstrap.ts
The core.bootstrap.ts file is the entrypoint of your application. Currently, it is mandatory for this file to exist (with that specific name), although that could change or be customizable later.
#### core/app.ts
This should be the top element of your application. This should be loaded by core/boot.ts (see below).

```
"use strict";
export class App {
...
constructor(){
console.log("Hello world!");
}
}
```

#### core/boot.ts
The boot.ts file is the entrypoint of your application. Currently, it is mandatory for this file to exist (with that specific name), although that could change or be customizable later.

The contents are actually not important but here's a starting point:

```
"use strict";
console.log("Hello world!");
import {App} from "core/app";
// bootstrap your app
```

#### styles/main.scss
Expand Down Expand Up @@ -666,6 +685,7 @@ Available options:
* distEntryPoint: must be a relative path from .tmp/ to the file to use as entry point for creating the production JS bundle. The extension does not need to be specified (JSPM is used to load the file)
* minifyProductionJSBundle: by default, the production JS bundle is minified, but you can disable it by setting this option to false
* mangleProductionJSBundle: by default, the production JS bundle is mangled, but you can disable it by setting this option to false
* minifyProductionHTML: by default, the production HTML is minified, but you can disable it by setting this option to false

## FAQ

Expand Down
3 changes: 3 additions & 0 deletions UPGRADE.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Upgrade guide

## From 0.2.1 to 0.2.2
If you are using Angular 2, you should set the minifyProductionHTML option to false (see changelog)

## From 0.2.0 to 0.2.1
No modification mandatory with this release.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "modern-web-dev-build",
"description": "Modern Web Development Build.",
"version": "0.2.1",
"version": "0.2.2",
"author": {
"name": "Sebastien Dubois",
"email": "[email protected]",
Expand Down
15 changes: 14 additions & 1 deletion src/gulp/tasks/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ class HtmlTaskLoader extends AbstractTaskLoader {
}
}

// Determine if HTML should be minified or not
let minifyProductionHTML = true;

if(typeof gulp.options.minifyProductionHTML !== "undefined"){
minifyProductionHTML = gulp.options.minifyProductionHTML;

if(minifyProductionHTML === false){
gutil.log("The HTML will NOT be minified!");
}
}

return gulp.plumbedSrc(
config.html.src
)
Expand All @@ -50,7 +61,9 @@ class HtmlTaskLoader extends AbstractTaskLoader {
}))

// Minify HTML
.pipe(iff(config.files.any + config.extensions.html, minifyHtml()))
.pipe(iff(minifyProductionHTML && config.files.any + config.extensions.html, minifyHtml({
quotes: true // do not remove quotes (Angular 2 does not like that)
})))

// Output files
.pipe(gulp.dest(config.html.dest))
Expand Down

0 comments on commit 9adc8af

Please sign in to comment.