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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel serve and watch commands ignoring target distDir configuration #9096

Open
bladeski opened this issue Jun 16, 2023 · 6 comments
Open

Comments

@bladeski
Copy link

馃悰 bug report

When running parcel serve or parcel watch commands, along with the --target parameter, the configuration for the target's distribution directory (either 'dist/<target_name>' or as per the distDir param under the target) is ignored, and the output is sent entirely to the default 'dist' directory.
This is particularly noticeable when multiple targets are specified, in which case the outputs for all targets are sent to the same 'dist' directory'.

Note that when running parcel build the problem does not exist and correct directories are observed.

This is similar, if not the same issue as the one closed here for inactivity: #8105

馃帥 Configuration (.babelrc, package.json, cli command)

.babelrc N/A

{
  "targets": { 
    "dev": {
      "source": [ "src/index.html" ]
    },
    "production": {
      "source": ["src/index.html"],
      "sourceMap": false
    }
  }
}

parcel serve --target dev

馃 Expected Behavior

Output for this command should be directed to:
/dist/dev/...

馃槸 Current Behavior

Output for this command is:
/dist/...

馃敠 Context

Trying to create simple (low config) tasks to help me develop locally

馃捇 Code Sample

(https://github.com/bladeski/b-links/tree/parcel-bug)

馃實 Your Environment

Software Version(s)
Parcel 2.9.2
Node 14.19.0
npm/Yarn 1.22.19
Operating System Windows 10
@davidjb
Copy link
Contributor

davidjb commented Dec 4, 2023

I'm seeing the same problem with parcel 2.10.3. With a config in package.json that matches https://parceljs.org/features/targets/#targets, trying to run parcel (to watch files) sees the default distDir option ignored and files continuing to be built in dist/. By comparison, parcel build correctly outputs to the distDir directory.

@mischnic
Copy link
Member

mischnic commented Dec 4, 2023

@davidjb
Copy link
Contributor

davidjb commented Dec 5, 2023

@mischnic I鈥檓 not sure what you mean. Do you mean that with parcel watch you need to explicitly add the --target default flag because there isn鈥檛 a default target? The docs you鈥檝e linked to seem to be able to be read in multiple ways.

I currently have

{
  "targets": {
    "default": {
      "distDir": "./output"
    }
  }
}

in my package.json but this default target isn鈥檛 used with watch.

@mischnic
Copy link
Member

mischnic commented Dec 5, 2023

What that linked section is trying to say: parcel serve and parcel watch by default don't use any of your explicit targets but uses a different one with last 1 Chrome version, last 1 Firefox version, ... as the browserslist setting (and also not inheriting any settings from your targets).

If you don't have any targets (but a browserslist setting), you can use parcel watch --target default to make it behave more like parcel build.

If you do have explicit targets (regardless of their names), use them instead for --target ...

@davidjb
Copy link
Contributor

davidjb commented Dec 5, 2023

Thanks for the explanation @mischnic.

It seems that the target doesn't apply (at least for distDir) when running parcel --target default; the default dist/ still gets generated. Setting distDir does work with parcel watch --target default, however. Is this expected or a bug?

Edit: running parcel watch --target default with the package.json config above generates dist files in the named distDir but trying to load http://localhost:1234 just leads to a 404 Not Found. So, this option doesn't appear to work correctly. The only workaround that works is adding the --dist-dir ./output flag.

@performantdata
Copy link

It seems that the target doesn't apply (at least for distDir) when running parcel --target default; the default dist/ still gets generated.

The only workaround that works is adding the --dist-dir ./output flag.

I can confirm that this is still an issue with parcel 2.11.0, and this workaround functions.

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

No branches or pull requests

4 participants