mzgoddard / hard-source-webpack-plugin

https://www.npmjs.com/package/hard-source-webpack-plugin
ISC License
2.71k stars 160 forks source link

building new cache every time #547

Open wzy4072 opened 3 years ago

wzy4072 commented 3 years ago
PS E:\tempWebpack> npm run build

> vue-antd-pro@3.0.0 build E:\tempWebpack
> vue-cli-service build
fatal: not a git repository (or any of the parent directories): .git

/  Building for production...[hardsource:ccc90cf8] Using 587 MB of disk space.
[hardsource:ccc90cf8] Writing new cache ccc90cf8...
[hardsource:ccc90cf8] Tracking node dependencies with: yarn.lock, node_modules/*.
\  Building for production...Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
....

it will Writing new cache every time, old cache was never used.

// vue.config.js 
  new HardSourceWebpackPlugin({
        configHash: require('node-object-hash')({ sort: false }).hash,
        environmentHash: {
          root: process.cwd(),
          directories: ['node_modules'],
          files: ['yarn.lock']
        }
      })

image

window 10
Node v12.16.1

  "scripts": {
    "dev": "vue-cli-service serve",
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint",
    "build:preview": "vue-cli-service build --mode preview",
    "lint:nofix": "vue-cli-service lint --no-fix"
  },
  "dependencies": {
    "@ant-design-vue/pro-layout": "^1.0.1",
    "@antv/data-set": "^0.10.2",
    "@antv/g2plot": "^2.3.18",
    "ant-design-vue": "^1.7.2",
    "axios": "^0.21.1",
    "babel-polyfill": "^6.26.0",
    "bpmn-js": "^8.2.0",
    "bpmn-js-properties-panel": "^0.38.1",
    "bpmn-moddle": "^7.0.4",
    "camunda-bpmn-moddle": "^4.0.1",
    "core-js": "^3.1.2",
    "default-passive-events": "^2.0.0",
    "echarts": "^5.0.0",
    "enquire.js": "^2.1.6",
    "fetch-jsonp": "^1.1.3",
    "file-saver": "^2.0.5",
    "flyio": "^0.6.14",
    "jquery": "^3.6.0",
    "js-base64": "^3.6.0",
    "jsbarcode": "^3.11.4",
    "lodash.clonedeep": "^4.5.0",
    "lodash.debounce": "^4.0.8",
    "lodash.get": "^4.4.2",
    "lodash.pick": "^4.4.0",
    "md5": "^2.2.1",
    "moment": "^2.24.0",
    "nprogress": "^0.2.0",
    "qrcodejs2": "^0.0.2",
    "querystring": "^0.2.1",
    "sm-crypto": "^0.2.4",
    "store": "^2.0.12",
    "vue": "^2.6.10",
    "vue-clipboard2": "^0.2.1",
    "vue-codemirror": "^4.0.6",
    "vue-cropper": "0.4.9",
    "vue-echarts": "^5.0.0-beta.0",
    "vue-i18n": "^8.17.4",
    "vue-ls": "^3.2.2",
    "vue-quill-editor": "^3.0.6",
    "vue-router": "^3.1.2",
    "vue-svg-component-runtime": "^1.0.1",
    "vuedraggable": "^2.24.3",
    "vuex": "^3.1.1",
    "wangeditor": "^3.1.1",
    "xlsx": "^0.16.9",
    "yarn": "^1.22.10"
  },
  "devDependencies": {
    "@ant-design/colors": "^3.2.1",
    "@babel/register": "^7.10.5",
    "@vue/cli-plugin-babel": "^4.0.4",
    "@vue/cli-plugin-eslint": "^4.0.4",
    "@vue/cli-plugin-router": "^4.0.4",
    "@vue/cli-plugin-unit-jest": "^4.0.4",
    "@vue/cli-plugin-vuex": "^4.0.4",
    "@vue/cli-service": "^4.0.4",
    "@vue/eslint-config-standard": "^4.0.0",
    "@vue/test-utils": "^1.0.0-beta.29",
    "babel-eslint": "^10.0.1",
    "babel-plugin-import": "^1.12.2",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint": "^5.16.0",
    "eslint-plugin-html": "^5.0.0",
    "eslint-plugin-vue": "^5.2.3",
    "git-revision-webpack-plugin": "^3.0.6",
    "hard-source-webpack-plugin": "^0.13.1",
    "less": "^3.0.4",
    "less-loader": "^5.0.0",
    "mockjs": "^1.1.0",
    "vue-svg-icon-loader": "^2.1.1",
    "vue-template-compiler": "^2.6.10",
    "webpack": "4.46.0",
    "webpack-theme-color-replacer": "^1.3.12"
  },
xaru123 commented 3 years ago

Hello! I have the same problem =( Did you find how to solve it?

leebolt528 commented 2 years ago

me too. Have you solved it?

chenjing0823 commented 2 years ago

I have the same problem, and finally i solved it. Because my project has dynamic configuration of configuration files. here is my solved step:

image image
chenjing0823 commented 2 years ago

再补充一下(都是中国人,我直接写中文了) 我这边之前多次新增新的缓存的时候,用上面的步骤仔细分析了一下。如果你有webpack一些动态配置,将会导致hash一直变化,然后同个项目,启动多个服务,端口的变化也意味着配置的编号。也会发生这样的问题。我这边动态的地方较少,可以去修复。已经可以正常使用了,但是如果你们无法做到的话。可以尝试直接写死的方式去实现,可以参考官网的例子

image image