diff --git a/package.json b/package.json
index f02551927..6fe74819f 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,9 @@
"gulp-autoprefixer": "^3.1.0",
"gulp-babel": "^6.1.1",
"gulp-cssnano": "^2.1.0",
+ "gulp-htmlmin": "^1.3.0",
+ "gulp-inline-source": "^2.1.0",
+ "gulp-minify-inline": "^0.2.0",
"gulp-rollup": "^1.7.0",
"gulp-sass": "^2.1.1",
"gulp-sourcemaps": "^1.6.0",
diff --git a/src/gulpfile.babel.js b/src/gulpfile.babel.js
index 562da9b93..faa833a1c 100644
--- a/src/gulpfile.babel.js
+++ b/src/gulpfile.babel.js
@@ -20,7 +20,9 @@
'use strict';
var gulp = require('gulp');
+var html = require('./wsk-tasks/html.js');
var sass = require('./wsk-tasks/sass.js');
+var babel = require('./wsk-tasks/babel.js');
GLOBAL.config = {
env: 'prod',
@@ -28,4 +30,7 @@ GLOBAL.config = {
dest: 'build'
};
-gulp.task('default', gulp.parallel([sass.build]));
+gulp.task('default', gulp.series([
+ gulp.parallel([sass.build, babel.build]),
+ html.build
+]));
diff --git a/src/src/index.html b/src/src/index.html
new file mode 100644
index 000000000..ae7db3200
--- /dev/null
+++ b/src/src/index.html
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
diff --git a/src/src/scripts/index.js b/src/src/scripts/index.js
new file mode 100644
index 000000000..939ee4a69
--- /dev/null
+++ b/src/src/scripts/index.js
@@ -0,0 +1,3 @@
+(function() {
+ console.log('Index is Loaded');
+})();
diff --git a/src/src/styles/index.scss b/src/src/styles/index.scss
new file mode 100644
index 000000000..aa1634c25
--- /dev/null
+++ b/src/src/styles/index.scss
@@ -0,0 +1,3 @@
+body {
+ background-color: red;
+}
diff --git a/src/wsk-tasks/babel.js b/src/wsk-tasks/babel.js
index f74cd6a62..4e254bb45 100644
--- a/src/wsk-tasks/babel.js
+++ b/src/wsk-tasks/babel.js
@@ -17,14 +17,16 @@
*
*/
-var gulp = require('gulp');
-var babel = require('gulp-babel');
-var uglify = require('gulp-uglify');
-var rollup = require('gulp-rollup');
-var sourcemaps = require('gulp-sourcemaps');
+'use strict';
+
+const gulp = require('gulp');
+const babel = require('gulp-babel');
+const uglify = require('gulp-uglify');
+const rollup = require('gulp-rollup');
+const sourcemaps = require('gulp-sourcemaps');
function build() {
- var stream = gulp.src(GLOBAL.config.src + '/**/*.js')
+ let stream = gulp.src(GLOBAL.config.src + '/**/*.js')
.pipe(sourcemaps.init())
.pipe(rollup())
.pipe(babel({
@@ -40,5 +42,5 @@ function build() {
}
module.exports = {
- build: build,
+ build: build
};
diff --git a/src/wsk-tasks/html.js b/src/wsk-tasks/html.js
new file mode 100644
index 000000000..ed70cc444
--- /dev/null
+++ b/src/wsk-tasks/html.js
@@ -0,0 +1,71 @@
+/**
+ *
+ * Web Starter Kit
+ * Copyright 2016 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ *
+ */
+
+'use strict';
+
+const gulp = require('gulp');
+const htmlmin = require('gulp-htmlmin');
+const inlineSource = require('gulp-inline-source');
+const minifyInline = require('gulp-minify-inline');
+
+function build() {
+ let stream = gulp.src(GLOBAL.config.src + '/**/*.html');
+
+ // We only want to minify for production builds
+ if (GLOBAL.config.env === 'prod') {
+ stream = stream.pipe(minifyInline({
+ js: {
+ output: {
+ comments: false
+ }
+ },
+ css: {
+ keepSpecialComments: 1
+ },
+ cssSelector: 'style[data-do-not-minify!="true"]'
+ }))
+ .pipe(inlineSource({
+ attribute: 'data-inline',
+ compress: false,
+ rootpath: GLOBAL.config.dest
+ }))
+ .pipe(htmlmin({
+ removeComments: true,
+ collapseWhitespace: true,
+ collapseBooleanAttributes: true,
+ removeAttributeQuotes: true,
+ removeRedundantAttributes: true,
+ removeEmptyAttributes: true,
+ removeScriptTypeAttributes: true,
+ removeStyleLinkTypeAttributes: true,
+ removeOptionalTags: true
+ }));
+ }
+
+ return stream.pipe(gulp.dest(GLOBAL.config.dest));
+}
+
+function watch() {
+ return gulp.watch(GLOBAL.config.src + '/**/*.html', build);
+}
+
+module.exports = {
+ build: build,
+ watch: watch
+};
diff --git a/src/wsk-tasks/sass.js b/src/wsk-tasks/sass.js
index d3ec1f0b1..4dd632f75 100644
--- a/src/wsk-tasks/sass.js
+++ b/src/wsk-tasks/sass.js
@@ -17,11 +17,13 @@
*
*/
-var gulp = require('gulp');
-var gulpSass = require('gulp-sass');
-var autoprefixer = require('gulp-autoprefixer');
-var cssnano = require('gulp-cssnano');
-var sourcemaps = require('gulp-sourcemaps');
+'use strict';
+
+const gulp = require('gulp');
+const gulpSass = require('gulp-sass');
+const autoprefixer = require('gulp-autoprefixer');
+const cssnano = require('gulp-cssnano');
+const sourcemaps = require('gulp-sourcemaps');
const AUTOPREFIXER_BROWSERS = [
'ie >= 11',
@@ -37,17 +39,17 @@ const AUTOPREFIXER_BROWSERS = [
];
function build() {
- var sassStream = gulp.src(GLOBAL.config.src + '/**/*.scss')
+ let stream = gulp.src(GLOBAL.config.src + '/**/*.scss')
.pipe(gulpSass().on('error', gulpSass.logError))
.pipe(sourcemaps.init())
.pipe(autoprefixer(AUTOPREFIXER_BROWSERS));
// We only want to minify for production builds
if (GLOBAL.config.env === 'prod') {
- sassStream = sassStream.pipe(cssnano());
+ stream = stream.pipe(cssnano());
}
- return sassStream.pipe(sourcemaps.write('.'))
+ return stream.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(GLOBAL.config.dest));
}
diff --git a/test/data/invalid-files/html/index.html b/test/data/invalid-files/html/index.html
new file mode 100644
index 000000000..9bb36de85
--- /dev/null
+++ b/test/data/invalid-files/html/index.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Test Index
+
+
+
diff --git a/test/data/valid-files-2/html/index.html b/test/data/valid-files-2/html/index.html
new file mode 100644
index 000000000..c3d66487b
--- /dev/null
+++ b/test/data/valid-files-2/html/index.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Test Index 2
+
+
+
diff --git a/test/data/valid-files-2/html/nest1.2/nest1.2.html b/test/data/valid-files-2/html/nest1.2/nest1.2.html
new file mode 100644
index 000000000..6f8656174
--- /dev/null
+++ b/test/data/valid-files-2/html/nest1.2/nest1.2.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Test 1.2
+
+
+
diff --git a/test/data/valid-files-2/html/nest1/nest1.html b/test/data/valid-files-2/html/nest1/nest1.html
new file mode 100644
index 000000000..db93ceff4
--- /dev/null
+++ b/test/data/valid-files-2/html/nest1/nest1.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Test 1 (From valid-files-2)
+
+
+
diff --git a/test/data/valid-files-2/html/nest1/nest2.2/nest2.2.html b/test/data/valid-files-2/html/nest1/nest2.2/nest2.2.html
new file mode 100644
index 000000000..c516f8184
--- /dev/null
+++ b/test/data/valid-files-2/html/nest1/nest2.2/nest2.2.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Test 2.2
+
+
+
diff --git a/test/data/valid-files-2/html/output.json b/test/data/valid-files-2/html/output.json
new file mode 100644
index 000000000..05fe827c2
--- /dev/null
+++ b/test/data/valid-files-2/html/output.json
@@ -0,0 +1,6 @@
+[
+ "index.html",
+ "nest1/nest1.html",
+ "nest1/nest2.2/nest2.2.html",
+ "nest1.2/nest1.2.html"
+]
diff --git a/test/data/valid-files-2/sass/nest1/nest2/nest2.scss b/test/data/valid-files-2/sass/nest1/nest2.2/nest2.2.scss
similarity index 100%
rename from test/data/valid-files-2/sass/nest1/nest2/nest2.scss
rename to test/data/valid-files-2/sass/nest1/nest2.2/nest2.2.scss
diff --git a/test/data/valid-files-2/sass/output.json b/test/data/valid-files-2/sass/output.json
index 1f6358bbd..62869a12a 100644
--- a/test/data/valid-files-2/sass/output.json
+++ b/test/data/valid-files-2/sass/output.json
@@ -1,6 +1,6 @@
[
"example.css",
"nest1/nest1.css",
- "nest1/nest2/nest2.css",
+ "nest1/nest2.2/nest2.2.css",
"nest1.2/nest1.2.css"
]
diff --git a/test/data/valid-files/html/index.html b/test/data/valid-files/html/index.html
new file mode 100644
index 000000000..529e4595a
--- /dev/null
+++ b/test/data/valid-files/html/index.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Test Index
+
+
+
diff --git a/test/data/valid-files/html/nest1/nest1.html b/test/data/valid-files/html/nest1/nest1.html
new file mode 100644
index 000000000..654f21de3
--- /dev/null
+++ b/test/data/valid-files/html/nest1/nest1.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Nest 1
+
+
+
diff --git a/test/data/valid-files/html/nest1/nest2/nest2.html b/test/data/valid-files/html/nest1/nest2/nest2.html
new file mode 100644
index 000000000..e325e0425
--- /dev/null
+++ b/test/data/valid-files/html/nest1/nest2/nest2.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Nest 2
+
+
+
diff --git a/test/data/valid-files/html/nest1/nest2/nest3/nest3.html b/test/data/valid-files/html/nest1/nest2/nest3/nest3.html
new file mode 100644
index 000000000..0b0f9777e
--- /dev/null
+++ b/test/data/valid-files/html/nest1/nest2/nest3/nest3.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Nest 3
+
+
+
diff --git a/test/data/valid-files/html/nest1/nest2/nest3/nest4/nest4.html b/test/data/valid-files/html/nest1/nest2/nest3/nest4/nest4.html
new file mode 100644
index 000000000..7e0d88dc2
--- /dev/null
+++ b/test/data/valid-files/html/nest1/nest2/nest3/nest4/nest4.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ Web Starter Kit
+
+
+
+
+
+
+
+
+
+ Nest 4
+
+
+
diff --git a/test/data/valid-files/html/output.json b/test/data/valid-files/html/output.json
new file mode 100644
index 000000000..8208f1333
--- /dev/null
+++ b/test/data/valid-files/html/output.json
@@ -0,0 +1,7 @@
+[
+ "index.html",
+ "nest1/nest1.html",
+ "nest1/nest2/nest2.html",
+ "nest1/nest2/nest3/nest3.html",
+ "nest1/nest2/nest3/nest4/nest4.html"
+]