Commit bf192743 authored by Tim Lucas's avatar Tim Lucas Committed by Tim Neutkens

Update the hash-statics example to support sub-dirs (#3015)

parent f2f987f0
......@@ -5,7 +5,8 @@
"transform-assets",
{
"extensions": ["txt", "svg", "png"],
"name": "/static/[name].[ext]?[sha512:hash:base64:7]"
"regExp": ".*/static/(.+)",
"name": "/static/[1]?[sha512:hash:base64:7]"
}
]
]
......
......@@ -26,6 +26,4 @@ now
This example shows how to import images, videos, etc. from `/static` and get the URL with a hash query allowing to use better cache without problems.
This example supports `.svg`, `.png` and `.txt` extensions, but it can be configured to support any possible extension changing the `extensions` array in the `.babelrc` file.
We also can modify the filename we're going to get, that filename has `/static` prepended so every file we require using this is going to have the format `/static/[name].[ext]?[hash]`, because of this all the files need to be placed directly inside the `static` directory.
This example supports `.svg`, `.png` and `.txt` extensions, but it can be configured to support any possible extension changing the `extensions` array in the `.babelrc` file.
\ No newline at end of file
// We need to use `require` instead of `import`
// They also must be assigned to a variable/constant
const logoSVG = require('../static/logo.svg')
const logoPNG = require('../static/logo.png')
const logoSVG = require('../static/images/logo.svg')
const logoPNG = require('../static/images/logo.png')
const txt = require('../static/file.txt')
export default () => (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment