Open jstcki opened 9 years ago
How about passing a package.json
to Packup instead of an index.js
and taking the value for the index script from the main
configuration?
To start a new project we could create a copy/pasteable script that creates an initial package.json
with an entry for Packup. This way each project clearly specifies the version of Packup it needs and we don't have to install Packup globally. But maybe this is not what we wanted to have with Packup, namely a binary that is available everywhere to run anything … Oh well :)
Regarding the HTML file: we haven't really experimented with it yet, but having the templated index.html
maybe obliviates the need for a real index.html
.
I'm not even sure the index.html template is that useful. And as far as I can tell, it's the only place we even use the information from package.json
. Using the main
property would be a pretty good approach though …
And yes, a global packup would only be useful for quick experiments but nothing more. I'd never put preferGlobal: true
anywhere :smile:
We could also use the entry
property of a webpack config … but then we're back to needing a configuration.
Currently packup can be run in one of three ways:
packup
(looks for anindex.js
in the current directory, uses that as entry file)packup somedir
(looks for anindex.js
in thesomedir
, uses that as entry file)packup somedir/somefile.js
(uses this file as entry file)The directory of the entry file is also set as webpack
resolve.root
andcontentBase
.Additionally, it looks for a
package.json
and anindex.html
in the directory of the entry file and uses those if available. Otherwise it supplies dummy package info (only used for populating the index.html template) and uses its own index.html template file.The problem is, that in our current setup
package.json
andindex.html
most often are not located in the same directory as the entry file. The actual code is in another directory, most oftensrc
. So we would either need another way to resolve the locations of necessary files outside this directory (e.g. using node-resolve) or allow other configuration options for packup. I prefer the former, although we may restrict lookup to only one level above the root directory.Edit: Not sure if node-resolve would work as I expected