Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9 from jasongrout/output
Browse files Browse the repository at this point in the history
Revamp the entry option and add an outputDir option to build configurations
  • Loading branch information
blink1073 committed Sep 15, 2016
2 parents eee48c7 + e1654ad commit ae7c879
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/builder.ts
Expand Up @@ -46,29 +46,26 @@ DEFAULT_LOADERS = [
export
function buildExtension(options: IBuildOptions) {
let name = options.name;
let entryPath = options.entryPath;

if (!name) {
throw Error('Must specify a name for the extension');
}
if (!entryPath) {
throw Error('Must specify an entryPath');
if (!options.entry) {
throw Error('Must specify an entry module');
}
try {
fs.statSync(path.join(process.cwd(), entryPath));
} catch (e) {
throw Error(`Invalid path to entry point: ${entryPath}`);
if (!options.outputDir) {
throw Error('Must specify an output directory');
}

// Create the named entry point to the entryPath.
let entry: { [key: string]: string } = {};
entry[name] = options.entryPath;
entry[name] = options.entry;

let config = new Config().merge({
// The default options.
entry: entry,
output: {
path: path.join(process.cwd(), 'build'),
path: path.resolve(options.outputDir),
filename: '[name].bundle.js',
publicPath: `labextension/${name}`
},
Expand Down Expand Up @@ -136,9 +133,20 @@ interface IBuildOptions {
name: string;

/**
* The path to the entry point.
* The module to load as the entry point.
*
* The module should export a plugin configuration or array of
* plugin configurations.
*/
entry: string;

/**
* The directory in which to put the generated bundle files.
*
* Relative directories are resolved relative to the current
* working directory of the process.
*/
entryPath: string;
outputDir: string;

/**
* Whether to extract CSS from the bundles (default is True).
Expand Down

0 comments on commit ae7c879

Please sign in to comment.