Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.
Binary file added bin/closure-compiler.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions config/cleancss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ module.exports = {
/**
* sourceFileName: the file name of the src css file
*/
sourceFileName: 'main.css',
sourceFileName: process.env.IONIC_OUTPUT_CSS_FILE_NAME,

/**
* destFileName: the file name for the generated minified file
*/
destFileName: 'main.css'
destFileName: process.env.IONIC_OUTPUT_CSS_FILE_NAME

};
4 changes: 2 additions & 2 deletions config/closure.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module.exports = {
* Note: if the executable is on the OS's PATH, often times
* `java` will suffice. Verify by running `java --version`
*/
pathToJavaExecutable: 'java'

pathToJavaExecutable: 'java',
pathToClosureJar: process.env.IONIC_CLOSURE_JAR
};
10 changes: 3 additions & 7 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ var rollupConfig = {
* be included, along with the minimum necessary code
* from its dependencies
*/
entry: process.env.IONIC_APP_ENTRY_POINT_PATH,
entry: process.env.IONIC_APP_ENTRY_POINT,

/**
* sourceMap: If true, a separate sourcemap file will
* be created.
*/
sourceMap: true,
sourceMap: process.env.IONIC_GENERATE_SOURCE_MAP ? true : false,

/**
* format: The format of the generated bundle
Expand All @@ -29,7 +29,7 @@ var rollupConfig = {
/**
* dest: the output filename for the bundle in the buildDir
*/
dest: 'main.js',
dest: process.env.IONIC_OUTPUT_JS_FILE_NAME,

/**
* plugins: Array of plugin objects, or a single plugin object.
Expand All @@ -52,9 +52,5 @@ var rollupConfig = {
};


if (process.env.IONIC_ENV === 'prod') {
rollupConfig.sourceMap = false;
}


module.exports = rollupConfig;
2 changes: 1 addition & 1 deletion config/sass.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
* from the sass build. The directory which it is saved in
* is set within the "buildDir" config options.
*/
outputFilename: 'main.css',
outputFilename: process.env.IONIC_OUTPUT_CSS_FILE_NAME,

/**
* sourceMap: If source map should be built or not.
Expand Down
8 changes: 4 additions & 4 deletions config/uglifyjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ module.exports = {
/**
* sourceFile: The javascript file to minify
*/
sourceFile: 'main.js',
sourceFile: process.env.IONIC_OUTPUT_JS_FILE_NAME,

/**
* destFileName: file name for the minified js in the build dir
*/
destFileName: 'main.js',
destFileName: process.env.IONIC_OUTPUT_JS_FILE_NAME,

/**
* inSourceMap: file name for the input source map
*/
inSourceMap: 'main.js.map',
inSourceMap: process.env.IONIC_OUTPUT_JS_MAP_FILE_NAME,

/**
* outSourceMap: file name for the output source map
*/
outSourceMap: 'main.js.map',
outSourceMap: process.env.IONIC_OUTPUT_JS_MAP_FILE_NAME,

/**
* mangle: uglify 2's mangle option
Expand Down
27 changes: 8 additions & 19 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
var path = require('path');
var webpack = require('webpack');

var ionicWebpackFactoryPath = path.join(process.env.IONIC_APP_SCRIPTS_DIR, 'dist', 'webpack', 'ionic-webpack-factory.js');
var ionicWebpackFactory = require(ionicWebpackFactoryPath);

function getDevtool() {
if (process.env.IONIC_ENV === 'prod') {
// for now, just force source-map for prod builds
return 'source-map';
}

return process.env.IONIC_SOURCE_MAP;
}
var ionicWebpackFactory = require(process.env.IONIC_WEBPACK_FACTORY);

module.exports = {
bail: true,
entry: process.env.IONIC_APP_ENTRY_POINT_PATH,
entry: process.env.IONIC_APP_ENTRY_POINT,
output: {
path: '{{BUILD}}',
filename: 'main.js',
filename: process.env.IONIC_OUTPUT_JS_FILE_NAME,
devtoolModuleFilenameTemplate: ionicWebpackFactory.getSourceMapperFunction(),
},
devtool: getDevtool(),
devtool: process.env.IONIC_GENERATE_SOURCE_MAP ? process.env.IONIC_SOURCE_MAP_TYPE : '',

resolve: {
extensions: ['.js', '.ts', '.json'],
extensions: ['.ts', '.js', '.json'],
modules: [path.resolve('node_modules')]
},

Expand All @@ -35,8 +23,9 @@ module.exports = {
loader: 'json-loader'
},
{
test: /\.(ts|ngfactory.js)$/,
loader: path.join(process.env.IONIC_APP_SCRIPTS_DIR, 'dist', 'webpack', 'typescript-sourcemap-loader-memory.js')
//test: /\.(ts|ngfactory.js)$/,
test: /\.ts$/,
loader: process.env.IONIC_WEBPACK_LOADER
}
]
},
Expand Down
8 changes: 3 additions & 5 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { bundle, bundleUpdate } from './bundle';
import { clean } from './clean';
import { copy } from './copy';
import { emit, EventType } from './util/events';
import { generateContext } from './util/config';
import { lint, lintUpdate } from './lint';
import { Logger } from './logger/logger';
import { minifyCss, minifyJs } from './minify';
Expand All @@ -17,7 +16,6 @@ import { transpile, transpileUpdate, transpileDiagnosticsOnly } from './transpil


export function build(context: BuildContext) {
context = generateContext(context);
setContext(context);
const logger = new Logger(`build ${(context.isProd ? 'prod' : 'dev')}`);

Expand All @@ -33,7 +31,7 @@ export function build(context: BuildContext) {
}

function handleDeprecations(error: Error) {
if (error && error.message && error.message.indexOf('ENOENT') >= 0 && error.message.indexOf(process.env.IONIC_APP_ENTRY_POINT_PATH)) {
if (error && error.message && error.message.indexOf('ENOENT') >= 0 && error.message.indexOf(process.env.IONIC_APP_ENTRY_POINT)) {
const error = new BuildError(`"main.dev.ts" and "main.prod.ts" have been deprecated. Please create a new file "main.ts" containing the content of "main.dev.ts", and then delete the deprecated files.
For more information, please see the default Ionic project main.ts file here:
https://github.com/driftyco/ionic2-app-base/tree/master/src/app/main.ts`);
Expand All @@ -55,7 +53,7 @@ function buildWorker(context: BuildContext) {
function validateRequiredFilesExist() {
// for now, just do the entry point
// eventually this could be Promise.all and load a bunch of stuff
return readFileAsync(process.env.IONIC_APP_ENTRY_POINT_PATH);
return readFileAsync(process.env.IONIC_APP_ENTRY_POINT);
}

function buildProject(context: BuildContext) {
Expand All @@ -75,7 +73,7 @@ function buildProject(context: BuildContext) {
const minPromise = (context.runMinifyJs) ? minifyJs(context) : Promise.resolve();
const sassPromise = sass(context)
.then(() => {
return (context.runMinifyCss) ? minifyCss(context) : Promise.resolve()
return (context.runMinifyCss) ? minifyCss(context) : Promise.resolve();
});

return Promise.all([
Expand Down
6 changes: 2 additions & 4 deletions src/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { BuildContext, ChangedFile } from './util/interfaces';
import { BuildError, IgnorableError } from './util/errors';
import { generateContext, BUNDLER_ROLLUP } from './util/config';
import { BUNDLER_ROLLUP } from './util/config';
import { rollup, rollupUpdate, getRollupConfig, getOutputDest as rollupGetOutputDest } from './rollup';
import { webpack, webpackUpdate, getWebpackConfig, getOutputDest as webpackGetOutputDest } from './webpack';


export function bundle(context?: BuildContext, configFile?: string) {
context = generateContext(context);

export function bundle(context: BuildContext, configFile?: string) {
return bundleWorker(context, configFile)
.catch((err: Error) => {
throw new BuildError(err);
Expand Down
5 changes: 1 addition & 4 deletions src/clean.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { BuildContext } from './util/interfaces';
import { BuildError } from './util/errors';
import { emptyDirSync } from 'fs-extra';
import { generateContext } from './util/config';
import { Logger } from './logger/logger';


export function clean(context?: BuildContext) {
context = generateContext(context);

export function clean(context: BuildContext) {
const logger = new Logger('clean');

try {
Expand Down
5 changes: 2 additions & 3 deletions src/cleancss.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { join } from 'path';
import { BuildContext, TaskInfo } from './util/interfaces';
import { BuildError } from './util/errors';
import { fillConfigDefaults, generateContext, getUserConfigFile } from './util/config';
import { fillConfigDefaults, getUserConfigFile } from './util/config';
import { Logger } from './logger/logger';
import { readFileAsync, writeFileAsync } from './util/helpers';
import { runWorker } from './worker-client';
import * as cleanCss from 'clean-css';


export function cleancss(context?: BuildContext, configFile?: string) {
context = generateContext(context);
export function cleancss(context: BuildContext, configFile?: string) {
configFile = getUserConfigFile(context, taskInfo, configFile);

const logger = new Logger('cleancss');
Expand Down
26 changes: 19 additions & 7 deletions src/closure.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { execSync } from 'child_process';
import { BuildContext, TaskInfo } from './util/interfaces';
import { generateContext, getUserConfigFile } from './util/config';
import { fillConfigDefaults, getUserConfigFile } from './util/config';
import { Logger } from './logger/logger';
import { runWorker } from './worker-client';


export function closure(context?: BuildContext, configFile?: string) {
context = generateContext(context);
export function closure(context: BuildContext, configFile?: string) {
configFile = getUserConfigFile(context, taskInfo, configFile);

const logger = new Logger('closure');
Expand All @@ -19,7 +18,6 @@ export function closure(context?: BuildContext, configFile?: string) {
});
}


export function closureWorker(context: BuildContext, configFile: string): Promise<any> {
return new Promise((resolve, reject) => {
Logger.warn('Closer Compiler unsupported at this time.');
Expand All @@ -28,11 +26,24 @@ export function closureWorker(context: BuildContext, configFile: string): Promis
}


export function isClosureSupported(context: BuildContext) {
// TODO: check for Java and compiler.jar executable
export function isClosureSupported(context: BuildContext): boolean{
/*const config = getClosureConfig(context, '');
try {
execSync(`${config.pathToJavaExecutable} --version`);
return true;
} catch (ex) {
Logger.debug('[Closure] isClosureSupported: Failed to execute java command');
return false;
}
*/
return false;
}

function getClosureConfig(context: BuildContext, configFile: string): ClosureConfig {
configFile = getUserConfigFile(context, taskInfo, configFile);

return fillConfigDefaults(configFile, taskInfo.defaultConfigFile);
}

const taskInfo: TaskInfo = {
fullArg: '--closure',
Expand All @@ -46,4 +57,5 @@ const taskInfo: TaskInfo = {
export interface ClosureConfig {
// https://developers.google.com/closure/compiler/docs/gettingstarted_app
pathToJavaExecutable: string;
pathToClosureJar: string;
}
8 changes: 3 additions & 5 deletions src/copy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mkdirpSync } from 'fs-extra';
import { dirname as pathDirname, join as pathJoin, relative as pathRelative, resolve as pathResolve } from 'path';
import { Logger } from './logger/logger';
import { fillConfigDefaults, generateContext, getUserConfigFile, replacePathVars } from './util/config';
import { fillConfigDefaults, getUserConfigFile, replacePathVars } from './util/config';
import { emit, EventType } from './util/events';
import { generateGlobTasks, globAll, GlobObject, GlobResult } from './util/glob-util';
import { copyFileAsync, rimRafAsync, unlinkAsync } from './util/helpers';
Expand All @@ -12,8 +12,7 @@ const copyFilePathCache = new Map<string, CopyToFrom[]>();

const FILTER_OUT_DIRS_FOR_CLEAN = ['{{WWW}}', '{{BUILD}}'];

export function copy(context?: BuildContext, configFile?: string) {
context = generateContext(context);
export function copy(context: BuildContext, configFile?: string) {
configFile = getUserConfigFile(context, taskInfo, configFile);

const logger = new Logger('copy');
Expand Down Expand Up @@ -241,8 +240,7 @@ function cleanConfigContent(dictionaryKeys: string[], copyConfig: CopyConfig, co
});
}

export function copyConfigToWatchConfig(context?: BuildContext): Watcher {
context = generateContext(context);
export function copyConfigToWatchConfig(context: BuildContext): Watcher {
const configFile = getUserConfigFile(context, taskInfo, '');
const copyConfig: CopyConfig = fillConfigDefaults(configFile, taskInfo.defaultConfigFile);
let results: GlobObject[] = [];
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from './util/config';
export * from './util/helpers';
export * from './util/interfaces';

import { generateContext } from './util/config';
import { getAppScriptsVersion } from './util/helpers';
import { Logger } from './logger/logger';

Expand All @@ -23,7 +24,8 @@ export function run(task: string) {
} catch (e) {}

try {
require(`../dist/${task}`)[task]().catch((err: any) => {
const context = generateContext(null);
require(`../dist/${task}`)[task](context).catch((err: any) => {
errorLog(task, err);
});
} catch (e) {
Expand Down
6 changes: 2 additions & 4 deletions src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { access } from 'fs';
import { BuildContext, ChangedFile, TaskInfo } from './util/interfaces';
import { BuildError } from './util/errors';
import { createProgram, findConfiguration, getFileNames } from 'tslint';
import { generateContext, getUserConfigFile } from './util/config';
import { getUserConfigFile } from './util/config';
import { join } from 'path';
import { Logger } from './logger/logger';
import { printDiagnostics, DiagnosticsType } from './logger/logger-diagnostics';
Expand All @@ -13,9 +13,7 @@ import * as fs from 'fs';
import * as ts from 'typescript';


export function lint(context?: BuildContext, configFile?: string) {
context = generateContext(context);

export function lint(context: BuildContext, configFile?: string) {
return runWorker('lint', 'lintWorker', context, configFile)
.catch(err => {
throw new BuildError(err);
Expand Down
4 changes: 1 addition & 3 deletions src/minify.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { BuildContext } from './util/interfaces';
import { cleancss } from './cleancss';
import { closure, isClosureSupported } from './closure';
import { generateContext } from './util/config';
import { Logger } from './logger/logger';
import { uglifyjs } from './uglifyjs';


export function minify(context?: BuildContext) {
context = generateContext(context);
export function minify(context: BuildContext) {

const logger = new Logger('minify');

Expand Down
7 changes: 3 additions & 4 deletions src/ngc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Logger } from './logger/logger';
import { generateContext, getUserConfigFile} from './util/config';
import { getUserConfigFile} from './util/config';
import { BuildContext, TaskInfo } from './util/interfaces';
import { AotCompiler } from './aot/aot-compiler';

export function ngc(context?: BuildContext, configFile?: string) {
context = generateContext(context);
export function ngc(context: BuildContext, configFile?: string) {
configFile = getUserConfigFile(context, taskInfo, configFile);

const logger = new Logger('ngc');
Expand All @@ -19,7 +18,7 @@ export function ngc(context?: BuildContext, configFile?: string) {
}

export function ngcWorker(context: BuildContext, configFile: string) {
const compiler = new AotCompiler(context, { entryPoint: process.env.IONIC_APP_ENTRY_POINT_PATH, rootDir: context.rootDir, tsConfigPath: process.env.IONIC_TS_CONFIG_PATH });
const compiler = new AotCompiler(context, { entryPoint: process.env.IONIC_APP_ENTRY_POINT, rootDir: context.rootDir, tsConfigPath: process.env.IONIC_TS_CONFIG });
return compiler.compile();
}

Expand Down
Loading