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

Commit

Permalink
Revamp the entry option and add an outputDir option to build configur…
Browse files Browse the repository at this point in the history
…ations.

The entry option should be a module, not necessarily a path, so we clarify the name.

We also often need to specify the output directory, so we abstract over the webpack config for the user.
  • Loading branch information
jasongrout committed Sep 15, 2016
1 parent eee48c7 commit 8d5bafe
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/builder.ts
Expand Up @@ -46,29 +46,23 @@ 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) {
if (!options.entry) {
throw Error('Must specify an entryPath');
}
try {
fs.statSync(path.join(process.cwd(), entryPath));
} catch (e) {
throw Error(`Invalid path to entry point: ${entryPath}`);
}

// 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 || './build'),
filename: '[name].bundle.js',
publicPath: `labextension/${name}`
},
Expand Down Expand Up @@ -136,9 +130,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 bundled files.
*
* Relative directories are resolved relative to the current
* working directory of the process. The default is './build'.
*/
entryPath: string;
outputDir: string;

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

0 comments on commit 8d5bafe

Please sign in to comment.