Skip to content

Commit

Permalink
Add name option to allow overriding the default of "[name]-[hash].[…
Browse files Browse the repository at this point in the history
…ext]"
  • Loading branch information
fracture91 committed Apr 27, 2021
1 parent 4755ff9 commit 4786d88
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ module.exports = withImages({
})
```

### Name
You can change the structure of the generated file names by passing the `name` option:

```js
// next.config.js
const withImages = require('next-images')
module.exports = withImages({
name: "[name].[hash:base64:8].[ext]",
webpack(config, options) {
return config
}
})
```

The default value is `"[name]-[hash].[ext]"`. Documentation for available tokens like `[name]`, `[hash]`, etc can be found in [webpack/loader-utils](https://github.com/webpack/loader-utils#interpolatename)

### ES Modules
> By default, file-loader generates JS modules that use the ES modules syntax. There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = ({ dynamicAssetPrefix = false, ...nextConfig } = {}) => {
''
}/_next/static/images/`,
}),
name: "[name]-[hash].[ext]",
name: nextConfig.name || "[name]-[hash].[ext]",
esModule: nextConfig.esModule || false
}
}
Expand Down

0 comments on commit 4786d88

Please sign in to comment.