How to disable chunkhash in neutrino.js?

555 Views Asked by At

I'm looking for a way to disable chunkhash in neutrino.js when building, but didn't find any documentation about it, anyone could help?

Updated:

As in webpack, I can customize the output.filename, in neutrino.js, it seems the string "[name].[hash].bundle.js" is baked in, and there's no way to remove [hash] as far as I can see.

1

There are 1 best solutions below

4
On BEST ANSWER

In your .neutrinorc.js file, you can add an additional override function to change the output filename to not include the chunk hash (using neutrino-preset-react as an example:

module.exports = {
  use: [
    'neutrino-preset-react',
    (neutrino) => {
      // the original value of filename is "[name].[chunkhash].js"
      neutrino.config.output.filename('[name].js');
    }
  ]
};

If you want to change build targets based on an environment variable:

module.exports = {
  use: ['neutrino-preset-react'],
  env: {
    NEUTRINO_TARGET: {
      desktop: {
        use: [
          (neutrino) => neutrino.config.output.filename('[name].js');
        ]
      },
      mobile: {
        use: [
          (neutrino) => neutrino.config.entry('mobile').add('index.mobile.js');
        ]
      }
    }
  }
};

Then you can run Neutrino twice with differing environments:

NEUTRINO_TARGET=desktop neutrino build
NEUTRINO_TARGET=mobile neutrino build