Hi, I am using Fortrabbit for my hosting and they have a S3-like type of object storage where you can store assets; in this case my mix-compiled CSS and JS. I was able to utilize the mix.webpackConfig parameter to build out my extension.
Install S3Plugin
npm install webpack-s3-plugin --save
Add this to your webpack.mix.js
mix.webpackConfig({
plugins: [
new S3Plugin({
s3Options: {
accessKeyId: '${KEY}',
secretAccessKey: '${SECRET}',
endpoint: '${SERVER}'
},
s3UploadOptions: {
Bucket: '${BUCKET}'
},
directory: 'public'
})
]
});
and replace ${KEY}, ${SECRET}, ${SERVER}, and ${BUCKET} with the appropriate strings..
Environment detection
Because I didn't want my assets to be uploaded when developing locally, I wrapped the above JS snippet with the following if statement:
if (process.env.npm_config_env === 'staging' || process.env.npm_config_env === 'production') {
}
Then you can run the following command to trigger the upload
npm run dev --env=staging
Hope this helps.