This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webpack): default webpack, set bundler via configs
- Loading branch information
Showing
22 changed files
with
864 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,61 @@ | ||
import { BuildContext, TaskInfo } from './util/interfaces'; | ||
import { BuildContext } from './util/interfaces'; | ||
import { BuildError } from './util/logger'; | ||
import { fillConfigDefaults, generateContext, getUserConfigFile } from './util/config'; | ||
import { generateContext, BUNDLER_ROLLUP } from './util/config'; | ||
import { rollup, rollupUpdate, getRollupConfig, getOutputDest as rollupGetOutputDest } from './rollup'; | ||
import { getWebpackConfig, webpack, webpackUpdate, getOutputDest as webpackGetOutputDest } from './webpack'; | ||
import { webpack, webpackUpdate, getWebpackConfig, getOutputDest as webpackGetOutputDest } from './webpack'; | ||
|
||
|
||
export function bundle(context?: BuildContext, configFile?: string) { | ||
context = generateContext(context); | ||
const bundleConfig = getBundleConfig(context, configFile); | ||
|
||
return createBundle(context, configFile, bundleConfig) | ||
return bundleWorker(context, configFile) | ||
.catch((err: Error) => { | ||
throw new BuildError(err); | ||
}); | ||
} | ||
|
||
function createBundle(context: BuildContext, configFile: string, bundleConfig: BundleConfig) { | ||
if (bundleConfig.useWebpack) { | ||
return webpack(context, configFile); | ||
} else { | ||
|
||
function bundleWorker(context: BuildContext, configFile: string) { | ||
if (context.bundler === BUNDLER_ROLLUP) { | ||
return rollup(context, configFile); | ||
} | ||
|
||
return webpack(context, configFile); | ||
} | ||
|
||
|
||
export function bundleUpdate(event: string, path: string, context: BuildContext) { | ||
const bundleConfig = getBundleConfig(context, null); | ||
if (bundleConfig.useWebpack) { | ||
return webpackUpdate(event, path, context, null) | ||
.catch( (err: Error) => { | ||
throw new BuildError(err); | ||
}); | ||
} else { | ||
if (context.bundler === BUNDLER_ROLLUP) { | ||
return rollupUpdate(event, path, context) | ||
.catch( (err: Error) => { | ||
.catch(err => { | ||
throw new BuildError(err); | ||
}); | ||
} | ||
|
||
return webpackUpdate(event, path, context, null) | ||
.catch(err => { | ||
throw new BuildError(err); | ||
}); | ||
} | ||
|
||
|
||
export function buildJsSourceMaps(context: BuildContext) { | ||
const bundleConfig = getBundleConfig(context, null); | ||
if (bundleConfig.useWebpack) { | ||
// TODO - read this from webpack config (could be multiple values) | ||
return true; | ||
} else { | ||
if (context.bundler === BUNDLER_ROLLUP) { | ||
const rollupConfig = getRollupConfig(context, null); | ||
return rollupConfig.sourceMap; | ||
} | ||
|
||
// TODO - read this from webpack config (could be multiple values) | ||
return true; | ||
} | ||
|
||
|
||
export function getJsOutputDest(context: BuildContext) { | ||
const bundleConfig = getBundleConfig(context, null); | ||
if (bundleConfig.useWebpack) { | ||
const webpackConfig = getWebpackConfig(context, null); | ||
return webpackGetOutputDest(context, webpackConfig); | ||
} else { | ||
if (context.bundler === BUNDLER_ROLLUP) { | ||
const rollupConfig = getRollupConfig(context, null); | ||
return rollupGetOutputDest(context, rollupConfig); | ||
} | ||
} | ||
|
||
function getBundleConfig(context: BuildContext, configFile: string) { | ||
configFile = getUserConfigFile(context, taskInfo, configFile); | ||
const bundleConfig: BundleConfig = fillConfigDefaults(configFile, taskInfo.defaultConfigFile); | ||
return bundleConfig; | ||
} | ||
|
||
const taskInfo: TaskInfo = { | ||
fullArgConfig: '--bundle', | ||
shortArgConfig: '-e', | ||
envConfig: 'ionic_bundle', | ||
defaultConfigFile: 'bundle.config' | ||
}; | ||
|
||
export interface BundleConfig { | ||
useWebpack: boolean; | ||
const webpackConfig = getWebpackConfig(context, null); | ||
return webpackGetOutputDest(context, webpackConfig); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
declare module "*"; | ||
declare module 'autoprefixer'; | ||
declare module 'rollup-pluginutils'; | ||
declare module 'rollup'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.