I have a Nuxt.js ^2.10.2
App.
When I do npm run dev
, the project builds perfectly.
When I do npm run build
then npm run start
. some JS files are getting 404 error.
ERROR
Request URL: http://localhost:3000/_nuxt/vendors.pages/account.pages/ca.pages/cart.pages/category/_id/
index.pages/checkout/_step/index.pages/.f705ad4d.1-0-128.js
Request Method: GET
Status Code: 404 Not Found
Remote Address: 127.0.0.1:3000
Referrer Policy: no-referrer-when-downgrade
The file exists on my project in dist/_nuxt/vendor.pages/......
with the correct filename .f705ad4d.1-0-128.js
my nuxt.config.js
build: {,
filenames: {
app: '[name].' + version + '.js',
chunk: '[name].' + version + '.js',
vendor: '[name].' + version + '.js',
manifest: '[name].' + version + '.js',
},
}
What am I doing wrong? As other files are loaded as normal.
Found the answer. Files starting with .
dont work. not sure how to fix it though
Temoporary Fix:
in my nuxt.config.js
I added
build: {
filenames: {
app: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
chunk: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js',
css: ({ isDev }) => isDev ? '[name].css' : '[contenthash].css',
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]',
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[hash:7].[ext]',
video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[hash:7].[ext]'
}
}
REFERECE: https://nuxtjs.org/api/configuration-build/#filenames
or just this would work too
build: {
filenames: {
chunk: ({ isDev }) => isDev ? '[name].js' : '[chunkhash].js'
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With