[英]Exclude folders and files in Laravel Mix and Webpack
How do I exclude specific folders and files to be uploaded to S3 using Laravel Mix and Webpack?如何使用 Laravel Mix 和 Webpack 排除要上传到 S3 的特定文件夹和文件?
I tried this solution https://laracasts.com/discuss/channels/laravel/laravel-mix-upload-files-to-s3 and https://medium.com/@avosalmon/cache-busting-using-laravel-mix-and-cloudfront-s3-eb222b569f88 but it's not doing what I want to do.我试过这个解决方案https://laracasts.com/discuss/channels/laravel/laravel-mix-upload-files-to-s3和https://medium.com/@avosalmon/cache-busting-using-laravel-mix -and-cloudfront-s3-eb222b569f88但它没有做我想做的事。
const mix = require('laravel-mix');
const S3Plugin = require('webpack-s3-plugin');
require('dotenv').config();
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel applications. By default, we are compiling the CSS
| file for the application as well as bundling up all the JS files.
|
*/
let webpackPlugins = [];
if (mix.inProduction()) {
webpackPlugins = [
new S3Plugin({
include: /.*\.(css|js|ico|jpg|png)$/,
s3Options: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: process.env.AWS_DEFAULT_REGION,
// endpoint: process.env.AWS_ENDPOINT,
},
s3UploadOptions: {
Bucket: process.env.AWS_BUCKET,
CacheControl: 'public, max-age=31536000'
},
directory: 'public',
})
];
}
mix.js('resources/js/alpine.js', 'public/js')
.js('resources/js/choices.js', 'public/js')
.js('resources/js/clipboard.js', 'public/js')
.js('resources/js/notyf.js', 'public/js');
mix.postCss('resources/css/app.css', 'public/css', [
require("tailwindcss"),
]);
mix.disableSuccessNotifications();
mix.webpackConfig({
plugins: webpackPlugins
});
mix.version();
When I run this code, it uploads all contents and folders with css, js, ico, jpg and png files.当我运行这段代码时,它会上传所有内容和文件夹,其中包含 css、js、ico、jpg 和 png 文件。 However, I want to exclude specific folder regardless if it contains (css, js, ico, jpg and png) files.
但是,我想排除特定文件夹,无论它是否包含(css、js、ico、jpg 和 png)文件。
Example folders inside the public directory公共目录中的示例文件夹
I think that you can use CopyWebpackPlugin
to move your files from the build/static directory, to your compiled destination.我认为您可以使用
CopyWebpackPlugin
将文件从 build/static 目录移动到编译目标。 You don't need to put your files in the source directory, but in a folder that you copy:您不需要将文件放在源目录中,而是放在您复制的文件夹中:
https://laravel-mix.com/docs/4.0/copying-files https://laravel-mix.com/docs/4.0/copying-files
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.