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

Deleting stale hashed files #6

Open
juddlyon opened this issue Jan 27, 2021 · 4 comments
Open

Deleting stale hashed files #6

juddlyon opened this issue Jan 27, 2021 · 4 comments

Comments

@juddlyon
Copy link

Hi Ben!

Thanks for creating this, I needed a replacement for laravel-mix-versionhash. Gonna check out your Agency set up soon.

I'm not able to delete the stale hashed files with force set to true in delOptions. Here's the output with debug turned on:

Manifest found: '../web/dist/mix-manifest.json'
Renamed '../web/dist/js/app.js' to '../web/dist/js/app.b1e46e01a3c3a84c3cd6.js' (delOptions '{"force":true}')
Renamed '../web/dist/css/app.css' to '../web/dist/css/app.36b4410866e3e76ee304.css' (delOptions '{"force":true}')
Finished updating '../web/dist/mix-manifest.json' with the new filenames:
 {
  '/js/app.js': '/js/app.b1e46e01a3c3a84c3cd6.js',
  '/css/app.css': '/css/app.36b4410866e3e76ee304.css'
}

The built files from previous runs are still there. Not a biggie but I'd like to nuke them.

The invocation:

if (mix.inProduction()) {
  mix.version();
  mix.then(() => {
    convertToFileHash({
      publicPath: '../web/dist',
      manifestFilePath: '../web/dist/mix-manifest.json',
      delOptions: { force: true },
      debug: true
    });
  });
}

Here are the versions I'm using:

  "devDependencies": {
    "laravel-mix": "^6.0.11",
    "laravel-mix-make-file-hash": "^2.2.0",
    "laravel-mix-purgecss": "^6.0.0",
    "postcss": "^8.2.4",
    "resolve-url-loader": "^3.1.2",
    "sass": "^1.32.5",
    "sass-loader": "^8.0.2"
  }

Please advise. Thanks!

@maksakoviliya
Copy link

I have the same problem? Is there a desicion?

@matejsvajger
Copy link

matejsvajger commented Aug 2, 2021

For those looking for a solution: I just installed rimraf and clean the public dir at the start of webpack.mix.js with:

rimraf('public/**/app.*.*', () => {});
rimraf('public/**/vendor.*.js', () => {});
rimraf('public/**/manifest.*.js', () => {});

*edit: could also be simplified as

rimraf('public/**/{app,vendor,manifest}.*.*', () => {});

@juddlyon
Copy link
Author

juddlyon commented Aug 2, 2021

@matejsvajger Thanks for sharing your solution, rimraf will do the job well!

@gmeligio
Copy link

I use laravel-mix-clean to delete all files and relay on regeneration with a configuration like this:

mix.clean({
    cleanOnceBeforeBuildPatterns: [
      '**/*',
      '!robots.txt',
      '!images/**',
      '!favicon*.ico',
    ],
  });

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

No branches or pull requests

4 participants