Aug 3, 2021
0
Level 6
Webpack.mix.js question
Hi Just updated my site to v8.xxx laravel and I have a question about the updated webpack. Previously in package.json i had the following custom npm run script
"prod": "npm run production",
"production": "mix --production",
"production-upload-s3": "cross-env NODE_ENV=production UPLOAD_S3=true node_modules/webpack/bin/webpack.js --config=node_modules/laravel-mix/setup/webpack.config.js"
However when i run npn run production-upload-s3 or any other production command ie npm run production, mix --production etc it starts deploying the assets to S3. Is there any documentation as to how to set up a custom npm script or shed any light on this issue. Or is it a case that i need to add ENV=production UPLOAD_S3=false to the standard npn run scripts? The version of mix I believe is "laravel-mix": "^6.0.27" so possibly may have to downgrade as the older version seem to work ok
if (mix.inProduction() && process.env.UPLOAD_S3) {
webpackPlugins = [
new S3Plugin({
logger: console,
include: /.*\.(css|js|svg|fonts|png|ico|json|map|jpg|jpeg)$/,
s3Options: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: process.env.AWS_DEFAULT_REGION,
httpOptions: {
timeout: 240000,
connectTimeout: 240000
}
},
s3UploadOptions: {
Bucket: process.env.AWS_BUCKET,
CacheControl: 'public, max-age=15552000, immutable'
},
basePath: '/',
directory: 'public_html'
})
]
}
Please or to participate in this conversation.