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

Add option to add additional directories to generate.cache snapshot #10080

Open
weotch opened this issue Nov 24, 2021 · 2 comments
Open

Add option to add additional directories to generate.cache snapshot #10080

weotch opened this issue Nov 24, 2021 · 2 comments

Comments

@weotch
Copy link

weotch commented Nov 24, 2021

Is your feature request related to a problem? Please describe.

We often use nuxt in a yarn workspace based monorepo like:

/library
/nuxt-app
  /nuxt.config.js
/shopify-theme
yarn.lock

When we push a commit up to Netlify and there is only changes to the library directory, we'll see a message like this in the deploy log:

11:03:26 AM: [success] Skipping webpack build as no changes detected

When nuxt-app depends on those changes to library, this means that the new build doesn't contain the fresh code change.

Describe the solution you'd like

I think this could be fixed with a nuxt.config.js option to provide our own patterns to globby here:

https://github.com/nuxt/nuxt.js/blob/853439ddf945b6ee358d5912e6e5a68009633c27/packages/cli/src/utils/generate.js#L162-L167

Since globby supports an array for its first argument, I think we could pass a value like:

await globby(['**/*.*', '../library/**/*.*'], {
  ...
}

Describe alternatives you've considered

We could move the rootDir out to the parent.

@IsraelOrtuno
Copy link
Contributor

IsraelOrtuno commented Jan 1, 2022

This is specially needed for monorepo applications. Could be great to be able to specify other folders from the nuxt.config.js file.

@weotch have you found an alternative? I have been dealing with this for a while now.

@IsraelOrtuno
Copy link
Contributor

IsraelOrtuno commented Jan 1, 2022

@weotch and others, I solved this issue by adding a symlink to that external folder.

  const coreCacheFolder = this.nuxt.options.srcDir + '/__libcache';

  this.nuxt.hook('generate:cache:ignore', () => {
    fs.symlink(path.resolve(__dirname, '../'), coreCacheFolder, 'dir', () => {});
  });

  this.nuxt.hook('generate:done', () => {
    if (!fs.existsSync(coreCacheFolder)) return;
    fs.unlinkSync(coreCacheFolder);
  });

In my case, this code is in a module file which is on the shared library folder and is that folder the one that contains a lot of reusable components. That's why I use ../. You could set there whatever path to your library folder.

Tested in localhost and Netlify. Working 👍

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

No branches or pull requests

3 participants