Skip to content

Commit

Permalink
Be more flexible about package main
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabriskie committed Jul 16, 2015
1 parent b08cf8e commit 1bbf5e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tasks/build
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ eval "MINIFY=1 $BUILD"

# Copy package
cp README.md build/
node -p 'p=require("./package");p.main="lib/main.js";p.scripts=p.devDependencies=undefined;JSON.stringify(p,null,2)' > build/package.json
node -p 'p=require("./package");p.scripts=p.devDependencies=undefined;JSON.stringify(p,null,2)' > build/package.json
6 changes: 5 additions & 1 deletion webpack.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ var COMPONENT_FILE = process.env.COMPONENT_FILE;
var COMPONENT_NAME = process.env.COMPONENT_NAME;
var plugins = [];

function getPackageMain() {
return require(path.resolve(BASE_DIR, 'package.json')).main;
}

if (process.env.MINIFY) {
plugins.push(
new webpack.optimize.UglifyJsPlugin()
Expand All @@ -13,7 +17,7 @@ if (process.env.MINIFY) {
}

module.exports = {
entry: path.resolve(BASE_DIR, 'lib/main.js'),
entry: path.resolve(BASE_DIR, getPackageMain()),
output: {
filename: path.resolve(BASE_DIR, 'dist/' + COMPONENT_FILE + '.js'),
library: COMPONENT_NAME,
Expand Down

0 comments on commit 1bbf5e6

Please sign in to comment.