Skip to content

Commit

Permalink
build(package): optimize gulp config, integrate a rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zhukov committed Apr 26, 2017
1 parent 9116238 commit 8a726d3
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 1,278 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# compiled output
/dist
/tmp
/compiled
/build

# dependencies
node_modules
Expand Down
51 changes: 40 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,43 @@
'use strict';
/**
* Load the TypeScript compiler, then load the TypeScript gulpfile which simply loads all
* the tasks. The tasks are really inside tools/gulp/tasks.
*/
var gulp = require('gulp');
var sass = require('gulp-sass');
var replace = require('gulp-replace');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var cleanCSS = require('gulp-clean-css');

const path = require('path');
var inlineResources = require('./scripts/inline-resources');

// Register TS compilation
require('ts-node').register({
project: path.join(__dirname, 'tools/gulp')
});
gulp.task('start', copySources);

require('./tools/gulp/gulpfile');
function copySources() {
gulp.src('./src/framework/**/*')
.pipe(gulp.dest('./build'))
.on('end', fixStyleUrl);
}

function fixStyleUrl() {
gulp.src(['./build/**/*.ts'])
.pipe(replace('.scss', '.css'))
.pipe(gulp.dest('./build'))
.on('end', autoprefixSass);
}

function autoprefixSass() {
gulp.src(['./build/**/*.component.scss', './build/**/*.component.theme.scss'])
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest('./build'))
.on('end', compileSass);
}

function compileSass() {
gulp.src('./build/**/*.component.scss')
.pipe(sass({
outputStyle: 'compressed'
}))
.pipe(cleanCSS())
.pipe(gulp.dest('./build'));
}

gulp.task('default', ['start']);
25 changes: 5 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"repository": "git+https://github.com/akveo/ng2-admin.git",
"scripts": {
"ng": "ng",
"ngh": "ngh",
"rimraf": "rimraf",
"ngc": "node_modules/.bin/ngc",
"compodoc": "./node_modules/.bin/compodoc",
"start": "ng serve",
"start:hmr": "ng serve --hmr",
Expand All @@ -22,7 +19,7 @@
"build:prod:aot": "npm run build -- --aot",
"build:ci": "npm run build:prod && npm run build:prod:aot",
"build:ghpages": "npm run build:prod:aot -- --base-href \"https://akveo.github.io/ng2-admin/\" && ngh",
"build:release": "gulp build:release",
"build:release": "rimraf build && gulp && ngc -p tsconfig.publish.json",
"test": "ng test -sr",
"test:coverage": "npm run clean:coverage && ng test -sr -cc",
"lint": "ng lint",
Expand All @@ -41,7 +38,6 @@
"angular",
"typescript",
"ng2-admin",
"nga-admin",
"ngx-admin",
"framework"
],
Expand All @@ -68,28 +64,18 @@
"devDependencies": {
"@angular/cli": "1.0.1",
"@angular/compiler-cli": "4.0.3",
"@types/chalk": "0.4.31",
"@types/gulp": "4.0.2",
"@types/jasmine": "2.5.38",
"@types/node": "6.0.69",
"@types/rimraf": "0.0.28",
"@types/run-sequence": "0.0.29",
"@types/rx": "2.5.33",
"angular-cli-ghpages": "0.5.0",
"autoprefixer": "6.7.7",
"browserstack-local": "1.3.0",
"chalk": "1.1.3",
"codelyzer": "2.0.1",
"compodoc": "0.0.41",
"gulp": "3.9.1",
"gulp-better-rollup": "1.1.1",
"gulp-clean": "0.3.2",
"gulp-autoprefixer": "3.1.1",
"gulp-clean-css": "3.0.4",
"gulp-connect": "5.0.0",
"gulp-htmlmin": "3.0.0",
"gulp-if": "2.0.2",
"gulp-replace": "0.5.4",
"gulp-sass": "3.1.0",
"gulp-sourcemaps": "2.4.1",
"gulp-sourcemaps": "2.6.0",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "3.2.0",
"karma": "1.4.1",
Expand All @@ -100,9 +86,8 @@
"karma-jasmine-html-reporter": "0.2.2",
"npm-run-all": "4.0.1",
"protractor": "5.1.1",
"resolve-bin": "0.4.0",
"rimraf": "2.6.1",
"run-sequence": "1.2.2",
"rollup": "0.41.6",
"stylelint": "7.9.0",
"ts-node": "2.0.0",
"tslint": "4.5.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function inlineStyle(content, urlResolver) {
const urls = eval(styleUrls);
return 'styles: [' +
urls.map(styleUrl => {
styleUrl = styleUrl.replace('.scss', '.css');
const styleFile = urlResolver(styleUrl);
const styleContent = fs.readFileSync(styleFile, 'utf-8');
const shortenedStyle = styleContent
Expand Down
31 changes: 0 additions & 31 deletions src/framework/auth/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
}
}



ul > li.arrow {
border-bottom: 11px solid $nga-user-menu-border !important;

Expand Down
31 changes: 0 additions & 31 deletions src/framework/theme/tsconfig.json

This file was deleted.

Empty file.
47 changes: 47 additions & 0 deletions tools/build/rollup.config.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export const ROLLUP_GLOBALS = {
// Angular dependencies
'@angular/animations': 'ng.animations',
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/forms': 'ng.forms',
'@angular/http': 'ng.http',
'@angular/platform-browser': 'ng.platformBrowser',
'@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
'@angular/platform-browser/animations': 'ng.platformBrowser.animations',
'@angular/platform-server': 'ng.platformServer',

// Rxjs dependencies
'rxjs/Subject': 'Rx',
'rxjs/add/observable/fromEvent': 'Rx.Observable',
'rxjs/add/observable/forkJoin': 'Rx.Observable',
'rxjs/add/observable/of': 'Rx.Observable',
'rxjs/add/observable/merge': 'Rx.Observable',
'rxjs/add/observable/throw': 'Rx.Observable',
'rxjs/add/operator/auditTime': 'Rx.Observable.prototype',
'rxjs/add/operator/toPromise': 'Rx.Observable.prototype',
'rxjs/add/operator/map': 'Rx.Observable.prototype',
'rxjs/add/operator/filter': 'Rx.Observable.prototype',
'rxjs/add/operator/do': 'Rx.Observable.prototype',
'rxjs/add/operator/share': 'Rx.Observable.prototype',
'rxjs/add/operator/finally': 'Rx.Observable.prototype',
'rxjs/add/operator/catch': 'Rx.Observable.prototype',
'rxjs/add/operator/first': 'Rx.Observable.prototype',
'rxjs/add/operator/startWith': 'Rx.Observable.prototype',
'rxjs/add/operator/switchMap': 'Rx.Observable.prototype',
'rxjs/Observable': 'Rx',
};

export const BUILD_CONFIG = {
sourceMap: false,
format: 'umd',
}

export function getLicenseBanner(libName, pjsonPath) {
const libVersion = require(pjsonPath).version;

return `/**
* @license ${libName} v${libVersion}
* Copyright (c) 2017 Akveo. https://github.com/akveo/ng2-admin/tree/ngx-admin/
* License: MIT
*/`;
}
22 changes: 22 additions & 0 deletions tools/build/rollup.config.theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {
ROLLUP_GLOBALS,
BUILD_CONFIG,
getLicenseBanner,
} from './rollup.config.common';

const globals = Object.assign({}, ROLLUP_GLOBALS, {
'immutable': 'immutable',
});

const banner = getLicenseBanner('@nga/theme', '../../src/framework/theme/package.json');

export default {
...Object.assign({}, BUILD_CONFIG, {
external: Object.keys(globals),
globals,
moduleName: 'nga.theme',
entry: 'dist/theme/index.js',
dest: 'dist/theme/bundles/theme.umd.js',
banner,
}),
}
24 changes: 0 additions & 24 deletions tools/gulp/constants.ts

This file was deleted.

3 changes: 0 additions & 3 deletions tools/gulp/gulpfile.ts

This file was deleted.

6 changes: 0 additions & 6 deletions tools/gulp/tasks/clean.ts

This file was deleted.

22 changes: 0 additions & 22 deletions tools/gulp/tasks/release.ts

This file was deleted.

Loading

0 comments on commit 8a726d3

Please sign in to comment.