Skip to content

The copyAssetsToPublic hook doesn't copy dotfiles files like .htaccess #26

Open

Description

@renekliment

Hi!

Due to

  1. the glob.sync() not having { dot: true } as the options parameter and
  2. the extenstion condition

dotfiles are not copied.

I have 2 questions:

  1. Is this intended behaviour?
  2. What is the condition for? What use-case does it solve?

Activity

  1. swyxio commented on Oct 28, 2020

    @swyxio
    Contributor

    hey! i wrote those lines of code. you're free to modify those for whatever needs. i'm not sure about the intention but perhaps it avoids internals like DS_Store and .git and CODEOWNERS. stuff like that shouldnt be exposed to public. but think we would be happy to accept a PR to improve this.

  2. vlisivka commented on Jul 22, 2021

    @vlisivka

    To copy CNAME and .nojekyll files, hook must look like that:

      {
        hook: 'bootstrap',
        name: 'copyAssetsToPublic',
        description:
          'Copies ./assets/ to the "distDir" defined in the elder.config.js. This function helps support the live reload process.',
        run: ({ settings }) => {
          // Note that this function doesn't manipulate any props or return anything.
          // It is just executed on the 'bootstrap' hook which runs once when Elder.js is starting.
    
          // Copy assets folder to public destination
          glob.sync(path.resolve(settings.rootDir, './assets/**/*'), {dot: true, nodir: true, ignore: ['.DS_Store']}).forEach((file) => {
            const relativeToAssetsFolder = path.relative(path.join(settings.rootDir, './assets'), file);
            const outputPath = path.resolve(settings.distDir, relativeToAssetsFolder);
            fs.ensureDirSync(path.parse(outputPath).dir);
            fs.outputFileSync(outputPath, fs.readFileSync(file));
          });
        },
      },
  3. markjaquith commented on Jul 13, 2022

    @markjaquith
    Contributor

    I ran into this issue today. I was trying to get a _redirects file sent to public for Cloudflare Pages, and it took me an embarrassing amount of time to figure out what was going on. I don't think the benefit here is worth the confusion. .git and CODEOWNERS shouldn't be in that folder. .DS_Store is in .gitignore so it won't end up leaving local Mac dev machines.

  4. added a commit that references this issue on Jul 13, 2022
    c23be27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions