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

Support excluding files and directories in static folder #22

Open
arihans opened this issue Jan 9, 2023 · 1 comment
Open

Support excluding files and directories in static folder #22

arihans opened this issue Jan 9, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@arihans
Copy link

arihans commented Jan 9, 2023

I am in a similar situation to #20.
I have my index.html file inside the static folder. And I don't want to copy the index.html file, which is processed by parcel and copied to dist. It would be nice to ignore the index.html in the target directory.

I have tried the single file example, and it just gave me parcel-reporter-static-files-copy missing error.

Steps to Reproduce

  1. Have your index.html inside src.
    Your project structure should look something like this -
    dist/
    node-modules/
    src/
      |- assets/
      |- utils/
      |- main.js
      |- index.html
    .parcelrc
    package.json
    
  2. package.json should be -
    {
      ...
      "source": "src/html"
      "scripts": {
          "start": "parcel -p 8000",
          "prebuild": "rm -rf dist",
          "build": "parcel build"
      },
      "devDependencies": {
          "parcel": "^2.8.2",
          "parcel-reporter-static-files-copy": "^1.5.0"
      },
      "staticFiles": {
          "staticPath": "src",
          "distDir": "dist"
      }
    
    }
    
  3. .parcelrc content -
    {
      "extends": ["@parcel/config-default"],
      "reporters":  ["...", "parcel-reporter-static-files-copy"]
    }
    
  4. Include main.js in index.html - <script type="module" src="main.js"></script>
  5. Running npm start results in some dependency resolution error in browser.
@elwin013
Copy link
Owner

Hi @arihans!

I am in a similar situation to #20. I have my index.html file inside the static folder. And I don't want to copy the index.html file, which is processed by parcel and copied to dist. It would be nice to ignore the index.html in the target directory.

Hm... That's something that is not expected (putting sources and static files in the same directory). Excluding looks like a nice feature.

But with the latest version it can be solved with multiple static file paths. Example can be found in in envFilter directory. For the project structure you mentioned configuration could look like this:

  "staticFiles": [
    {
      "staticPath": "assets",
      "staticOutPath": "assets"
    },
    {
      "staticPath": "utils",
      "staticOutPath": "utils"
    }
  ]

Regarding other elements from issue:

I have tried the single file example, and it just gave me parcel-reporter-static-files-copy missing error.

I've checked and it works perfectly for me with the latest version. Could you provide more info (e.g. what OS, what config, maybe repo with reproduction in that case)?

...chomp...
5. Running npm start results in some dependency resolution error in browser.

Yep, index.html is overwritten by one from src directory. Because of that it loads main.js instead of main.somehash.js - the latter is ready to run in browser and the former could not be.

@elwin013 elwin013 added the enhancement New feature or request label Jul 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants