Nothing code specific, but here you go:
// resources/js/Pages/Homepage.vue
<template>
<div>
<img src="../../images/logo.jpg" />
</div>
</template>
<script>
export default {
name: 'Homepage'
}
</script>
Webpack automatically copies the logo.jpg from the images directory to the public/images folder. Vapor picks this up and uploads the asset to s3.
However, the img src is never updated to the new s3 url, like the js files are.
My mix file:
const mix = require('laravel-mix');
require('laravel-mix-tailwind');
require('laravel-mix-purgecss');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.postCss('resources/css/app.css', 'public/css')
.tailwind('./tailwind.config.js');
mix.js('resources/js/app.js', 'public/js')
.webpackConfig({
output: { chunkFilename: 'js/[name].js?id=[chunkhash]' },
resolve: {
alias: {
'vue$': 'vue/dist/vue.runtime.esm.js',
'@': path.resolve('resources/js'),
},
},
})
.babelConfig({
plugins: ['@babel/plugin-syntax-dynamic-import']
})
if (mix.inProduction()) {
const ASSET_URL = process.env.ASSET_URL + "/";
mix.webpackConfig(webpack => {
return {
plugins: [
new webpack.DefinePlugin({
"process.env.ASSET_PATH": JSON.stringify(ASSET_URL)
})
],
output: {
publicPath: ASSET_URL
}
};
});
mix.version();
mix.purgeCss({
whitelistPatterns: [],
whitelistPatternsChildren: [],
});
}