Skip to content

Commit c7a9807

Browse files
committed
Added minification and licensing to build
1 parent db50526 commit c7a9807

File tree

5 files changed

+86
-13
lines changed

5 files changed

+86
-13
lines changed

Diff for: LICENSE

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
22-
21+
SOFTWARE.

Diff for: gulpfile.js

+33-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ var require;
44

55
var browserify = require("browserify");
66
var del = require("del");
7+
var fs = require("file-system");
78
var globby = require("globby");
89
var gulp = require("gulp");
10+
var header = require("gulp-header");
911
var less = require("gulp-less");
1012
var merge = require("merge-stream");
1113
var minifyCSS = require("gulp-cssnano");
@@ -14,11 +16,11 @@ var plumber = require("gulp-plumber");
1416
var qunit = require("node-qunit-phantomjs");
1517
var rename = require("gulp-rename");
1618
var runSequence = require("run-sequence");
17-
var shell = require("gulp-shell");
1819
var source = require("vinyl-source-stream");
1920
var ts = require("gulp-typescript");
2021
var tslint = require("gulp-tslint");
2122
var typings = require("gulp-typings");
23+
var uglify = require("gulp-uglify");
2224

2325
var PATHS = {
2426
SRCROOT: "src/",
@@ -112,7 +114,6 @@ gulp.task("compile", function (callback) {
112114
////////////////////////////////////////
113115
// TSLINT
114116
////////////////////////////////////////
115-
//The actual task to run
116117
gulp.task("tslint", function () {
117118
var tsErrorReport = tslint.report("prose", {
118119
emitError: false,
@@ -131,10 +132,19 @@ gulp.task("tslint", function () {
131132
////////////////////////////////////////
132133
// BUNDLE
133134
////////////////////////////////////////
135+
function getLicense() {
136+
return [
137+
"/*",
138+
fs.readFileSync("LICENSE", "utf8"),
139+
"*/"
140+
].join("\n");
141+
}
142+
134143
gulp.task("bundlePicker", function() {
135144
return browserify(PATHS.BUILDROOT + "scripts/oneNotePicker.js", { standalone: "OneNotePicker" })
136145
.bundle()
137146
.pipe(source("oneNotePicker.js"))
147+
.pipe(header(getLicense()))
138148
.pipe(gulp.dest(PATHS.BUNDLEROOT));
139149
});
140150

@@ -156,6 +166,22 @@ gulp.task("bundle", function(callback) {
156166
callback);
157167
});
158168

169+
////////////////////////////////////////
170+
// MINIFY BUNDLED
171+
////////////////////////////////////////
172+
gulp.task("minifyBundled", function (callback) {
173+
var targetDir = PATHS.BUNDLEROOT;
174+
175+
var minifyTask = gulp.src(PATHS.BUNDLEROOT + "oneNotePicker.js")
176+
.pipe(uglify({
177+
preserveComments: "license"
178+
}))
179+
.pipe(rename({ suffix: ".min" }))
180+
.pipe(gulp.dest(targetDir));
181+
182+
return merge(minifyTask);
183+
});
184+
159185
////////////////////////////////////////
160186
// EXPORT - HELPER FUNCTIONS
161187
////////////////////////////////////////
@@ -204,17 +230,16 @@ function exportTestLibFiles() {
204230
////////////////////////////////////////
205231
// EXPORT - TASKS
206232
////////////////////////////////////////
207-
208233
gulp.task("exportPicker", function() {
209234
var modulesTask = gulp.src(PATHS.BUILDROOT + "scripts/**/*.js", { base: PATHS.BUILDROOT + "/scripts" })
210235
.pipe(gulp.dest(PATHS.TARGET.ROOT + "modules/"));
211236

212237
var commonTask = exportCommonFiles(PATHS.TARGET.ROOT);
213238
var copyTask = gulp.src([
214-
PATHS.BUNDLEROOT + "oneNotePicker.js",
215-
PATHS.SRCROOT + "oneNotePicker.d.ts"
216-
])
217-
.pipe(gulp.dest(PATHS.TARGET.ROOT));
239+
PATHS.BUNDLEROOT + "oneNotePicker.js",
240+
PATHS.BUNDLEROOT + "oneNotePicker.min.js",
241+
PATHS.SRCROOT + "oneNotePicker.d.ts"
242+
]).pipe(gulp.dest(PATHS.TARGET.ROOT));
218243

219244
return merge(modulesTask, copyTask, commonTask);
220245
});
@@ -249,6 +274,7 @@ gulp.task("build", function (callback) {
249274
"less",
250275
"compile",
251276
"bundle",
277+
"minifyBundled",
252278
"export",
253279
"tslint",
254280
"runTests",

Diff for: package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.3",
2+
"version": "1.0.4",
33
"name": "onenotepicker",
44
"description": "A JavaScript UI component that allows a user to choose one of their Notebook Sections",
55
"main": "target/modules/oneNotePicker.js",
@@ -14,17 +14,19 @@
1414
"browserify": "^13.0.0",
1515
"del": "^2.0.2",
1616
"es6-promise": "^3.0.2",
17+
"file-system": "^2.2.1",
1718
"globby": "^4.0.0",
1819
"gulp": "^3.9.0",
1920
"gulp-cssnano": "^2.1.1",
21+
"gulp-header": "^1.8.8",
2022
"gulp-less": "^3.0.3",
2123
"gulp-msx": "^0.4.0",
2224
"gulp-plumber": "^1.0.1",
2325
"gulp-rename": "^1.2.2",
24-
"gulp-shell": "^0.5.1",
2526
"gulp-tslint": "^5.0.0",
2627
"gulp-typescript": "^2.9.2",
2728
"gulp-typings": "~1.1.0",
29+
"gulp-uglify": "^1.5.3",
2830
"merge-stream": "^1.0.0",
2931
"mithril": "^0.2.4",
3032
"node-qunit-phantomjs": "^1.4.0",
@@ -35,5 +37,5 @@
3537
"typings": "~0.6.8",
3638
"vinyl-source-stream": "^1.1.0"
3739
},
38-
"files": ["README.*", "target/oneNotePicker.d.ts", "target/oneNotePicker.js", "target/css/*", "target/images/*"]
40+
"files": ["README.*", "target/oneNotePicker.d.ts", "target/oneNotePicker.js", "target/oneNotePicker.min.js", "target/css/*", "target/images/*"]
3941
}

Diff for: target/oneNotePicker.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OneNotePicker = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1+
/*
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2016 OneNoteDev
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
*/(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.OneNotePicker = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
224
/// <reference path="../../../typings/main/ambient/mithril/mithril.d.ts"/>
325
"use strict";
426
var KeyCode;

0 commit comments

Comments
 (0)