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

Custom ignore pattern for public folder copy #2231

Closed
miljan-aleksic opened this issue Aug 15, 2018 · 8 comments

Comments

@miljan-aleksic
Copy link

commented Aug 15, 2018

What problem does this feature solve?

I have assets that are used exlusively for the development and currently I am deleting those after build, but that approach is not ideal. Among others because cli analytics is taking those into account and providing missleading information.

What does the proposed API look like?

// vue.config.js
module.exports = {
  publicIgnore: [] // glob pattern
]
@LinusBorg

This comment has been minimized.

Copy link
Member

commented Aug 15, 2018

I don't think that we should add yet another config option for this use case, it doesn't seem common to me, but I may be mistaken. Can you elaborate on your use case a bit?

In any case, you can tweak the webpack config for this:

chainwebpack: config => {
  config.plugin('copy').tap([options] => {
    options[0].ignore.push('some/glob')
    return [options]
  })
}

https://github.com/webpack-contrib/copy-webpack-plugin#ignore

@yyx990803

This comment has been minimized.

Copy link
Member

commented Aug 15, 2018

What @LinusBorg said - but make sure to use push as concat is non-mutating ;)

@yyx990803 yyx990803 closed this Aug 15, 2018

@miljan-aleksic

This comment has been minimized.

Copy link
Author

commented Aug 15, 2018

That works perfectly. Thank you guys!

@janrode

This comment has been minimized.

Copy link

commented Aug 16, 2018

@miljan-aleksic did the example above work for you?
I always get an empty object for options[0]

@miljan-aleksic

This comment has been minimized.

Copy link
Author

commented Aug 16, 2018

Probably you omited the destructuring. This is my code:

config.plugin('copy').tap(([options]) => {
  options[0].ignore.push('somefolder/**/*')
  return [options]
})
@tomknappramos

This comment has been minimized.

Copy link

commented Apr 17, 2019

Thinking maybe my version of node is outdated, but the [options] syntax gave me an error. 😮

This worked for me:

chainWebpack: config => {

  config.plugin('copy').tap(options => {
    options[0][0].ignore.push('/**/*');
  });

}

'/**/*' is for ignoring everything in public/. 👍

@cpietsch

This comment has been minimized.

Copy link

commented Jun 2, 2019

@tomknappramos code works but is missing a return options;

chainWebpack: config => {
  config.plugin('copy').tap(options => {
    options[0][0].ignore.push('folderToExclude/**/*');
    return options;
  });
}
@mamsori

This comment has been minimized.

Copy link

commented Jun 5, 2019

@miljan-aleksic did the example above work for you?
I always get an empty object for options[0]

I've noticed that this error occurred if I added a --modern option
and I found out this solution that you need to filter out for a legacy bundle as like below

const isLegacyBundle = process.env.VUE_CLI_MODERN_MODE && !process.env.VUE_CLI_MODERN_BUILD;

if (!isLegacyBundle) {
	// input any plugin reference here
	config.plugin('copy').tap(([options]) => {
		options[0].ignore.push('folderToExclude/**/*');
		return [options];
	});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.