Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set a directory as entry point #1239

Closed
brandedoutcast opened this issue Apr 24, 2018 · 4 comments
Closed

Set a directory as entry point #1239

brandedoutcast opened this issue Apr 24, 2018 · 4 comments
Labels

Comments

@brandedoutcast
Copy link

🙋 feature request

🤔 Expected Behavior

Being able to provide a directory as an entry point. Parcel can then process all files in that directory & spit them out to dist folder

😯 Current Behavior

Parcel requires a file as an entry point which helps in computing & processing the dependencies

💁 Possible Solution

#189 might help in providing a possible solution. I guess even the dependency computation can be skipped as all files in the directory can be processed as one-to-one

Although, I'm not sure about a situation where few files in the directory need to be bundled together as a single file post processing

🔦 Context

In a simple setup like this, where src directory is the entry point for parcel it should be able to produce the files in dist directory

.
|-- src
    |-- bg.ts
    |-- content.ts
    |-- manifest.json
    |-- popup.jade
    |-- popup.ts
    |-- popup.styl
|-- dist
    |-- bg.js
    |-- content.js
    |-- manifest.json
    |-- popup.html
    |-- popup.js
    |-- popup.css
|-- .babelrc
|-- .gitignore
|-- package.json

Although the sample directory structure resembles a web extension (#1039), it might not always be the case & being able to point to a directory handles a lot of use-cases

@dobesv
Copy link
Contributor

dobesv commented May 18, 2018

Can't you just run parcel build src/* ?

@brandedoutcast
Copy link
Author

Thanks @dobesv I never knew I could do that 😱

Observations using parcel build src\* 👨‍🔬

  • manifest.json gets converted to manifest.js file 😕
  • if there's a sub-directory under src then parcel treats it as a module & throws an error saying it cannot find module 😑

I did get away with parcel build src\*.ts src\*.jade src\*.styl though 😍

@dobesv
Copy link
Contributor

dobesv commented May 19, 2018 via email

@muzea
Copy link

muzea commented Apr 23, 2019

I also have this demand. I want to compile all the files in a directory, the directory structure is similar to the following

src
├── api
│   └── test.ts
├── index.ts
└── static
    └── index.html

This is an http application that decides which api to load based on a request parameter.

index.ts is like

import Koa from 'koa';

const app = new Koa();

app.use(async ctx => {
  const func = require('./api/' + ctx.request.query.funcName);
  ctx.body = func();
});

app.listen(3000);

Now I can use parcel build src/* src/**/* --target node --out-dir build, but this writing doesn't look so good, I hope I can combine src/* src/**/* into one parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants