9

When I run npm run build I get the following error message.

[copy-webpack-plugin] unable to locate 'path\to\project\public' at 'path\to\project\public'

I moved the public folder to src/main/resources/public. However I can't find a config to change the path. I think the relevant code is in node_modules\@vue\cli-service\lib\config\app.js

// copy static assets in public/
webpackConfig
  .plugin('copy')
    .use(require('copy-webpack-plugin'), [[{
      from: api.resolve('public'),
      to: api.resolve(options.outputDir),
      ignore: ['index.html', '.DS_Store']
    }]])

How do I override this in vue.config.js?

1
  • You should simply take a look at your webpack.config.json file Commented Mar 15, 2018 at 14:13

1 Answer 1

10

This works for me using vue-cli 3.0. Just add it to your vue.config.js file.

module.exports = {
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        return [{template: '/path/to/index.html'}]
      })
  }
}

Though this might be more technically correct.

module.exports = {
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        args[0] = {
            template: '/path/to/index.html'
        }
        return args
      })
  }
}

Edit:

Actually this would be the preferred way of doing this so that none of the other defaults are overwritten.

module.exports = {
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        args[0].template = '/path/to/index.html'
        return args
      })
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

This works, but path has to start with ./ otherwise you get some error module could not be resolved so ./path/to/index.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.