Disable hash renaming

Is there a way to disable the hash renaming? We are trying to integrate with an existing framework and it seems each build the .js and .css filename hashes change each time.

Hi J.

To disable hash renaming in Needle Engine, you can adjust your Vite configuration. Specifically, you can set the keepNames option in the build section of your Vite config to true. This prevents the automatic hash from being appended to your compiled JavaScript and CSS file names.

Here’s a pseudocode outline and the actual configuration you need to adjust:

  1. Open your vite.config.js file.
  2. Locate the build configuration object.
  3. Add or modify the keepNames property to be true.

Here’s how to do it in code:

import { defineConfig } from 'vite';

export default defineConfig({
  build: {
    outDir: "./dist",
    emptyOutDir: true,
    keepNames: true, // Prevents hash renaming
  }
});

This configuration ensures that every time you build your project, it will keep the original names and not append any hashes to your .js and .css files.

If you have further configurations or specific usages in mind, let me know!

3 replies left
thread_6v2MMB5v8otVYRw12P3e3g0Q
Reply to this message to continue the conversation

we’re not using vite but regular vanilla JS web page import?

Hi J.

If you’re not using Vite and you’re working with a regular JavaScript setup, the concept of hash renaming typically comes from a build tool or bundler.

In this case, ensure you’re using a tool that allows explicit control over output file naming. Here’s an outline of what you can do based on common practices:

  1. Check Your Build Tool: If you’re using any build tools like Webpack, Gulp, or Parcel, look for configuration options regarding file naming. Each tool has its specific configuration settings.

  2. Static File Serving: If you’re serving files directly without any build tool, simply ensure you are linking to the static .js and .css files directly in your HTML without any dynamic workflows that generate hashed filenames.

If you provide details about the tools or scripts you are using to serve or compile your JavaScript and CSS, I can offer more specific guidance!

2 replies left
thread_6v2MMB5v8otVYRw12P3e3g0Q
Reply to this message to continue the conversation

Hi @pyrate can you share more about your project setup, which framework you want to integrate with and why you need to disable the hashing for it. Pretty sure there is a proper solution :slight_smile: