How to make Vue-Cli 3 ignore file changes in public folder
Asked Answered
T

1

7

I need to put a lot of js files in the public/js folder.This causes the CPU to reach 100%.

File path:

src
public
    - js 
        - 1.js
        - 2.js
        - ...
node_modules

These js files will not be updated. How to make Vue-Cli not observe these files?

I tried this configuration in vue.config.js but it doesn't work.

const path = require('path');
module.exports = {
  configureWebpack: {
    devServer: {
      watchOptions: {
        ignored: ['node_modules', 'public'],
      }
    }
  }
}
Tomasine answered 2/7, 2019 at 12:35 Comment(2)
Are you importing or requiring files in your project from the public js files?Suspender
No import and require.These js files will be loaded directly using an absolute path.Tomasine
S
16

I think the documentation may be wrong on how to do the ignore. Try it this way using regex instead. /public/

module.exports = {
  configureWebpack: {
    devServer: {
      watchOptions: {
        ignored: [/node_modules/, /public/],
      }
    }
  }
}

Also, you probably already know, but be sure to stop and then restart npm run watch or the new config options won't take affect.

Suspender answered 2/7, 2019 at 13:32 Comment(3)
Where do I put this?Elevon
@Elevon into vue.config.js in your package rootBerna
Thank you so much. This was driving me crazy as I had webpack-assets-manifest continously rebuilding manifest.json which causes the entire page to reload.Intersection

© 2022 - 2024 — McMap. All rights reserved.