简体   繁体   English

Laravel 5.4 为 npm run watch 指定文件

[英]Laravel 5.4 specify files for npm run watch

The Laravel mix docs indicate that npm run watch will run "all relevant files for changes." Laravel mix 文档表明npm run watch将运行“所有相关文件进行更改”。 But where do I see which files are relevant?但是我在哪里可以看到哪些文件是相关的?

Specifically, I have some files in resources/assets/js/components that I'd like to have compiled.具体来说,我在resources/assets/js/components中有一些我想编译的文件。 But say I had an arbitrary file that I also wanted to include.但是假设我有一个我也想包含的任意文件。

How would one specify that?如何指定呢?

CLARIFICATION澄清

I may have not been clear enough in my original post, so I'll try again.可能是我原帖说的不够清楚,我再试试。

What I'm looking for is the list of files and/or directories that TRIGER npm run watch to (re)compile all assets;我正在寻找的是TRIGER npm run watch以(重新)编译所有资产的文件和/或目录列表; and how to edit that list.以及如何编辑该列表。

where do I see which files are relevant?我在哪里可以看到哪些文件是相关的?

All the files that were included in webpack.mix.js file. webpack.mix.js文件中包含的webpack.mix.js文件。

Specifically, I have some files in resources/assets/js/components that I'd like to have compiled.具体来说,我在资源/资产/js/组件中有一些我想编译的文件。

Just add them in the webpack.mix.js file, for example:只需将它们添加到webpack.mix.js文件中,例如:

mix.js([
    'resources/assets/js/components/foo.js',
    'resources/assets/js/components/ba.js'
], 'public/js/app.js');

Once you edit them, webpack will compile your files in app.js file.一旦你编辑它们,webpack 会在app.js文件中编译你的文件。

But say I had an arbitrary file that I also wanted to include.但是假设我有一个我也想包含的任意文件。

Same trick.同样的把戏。 Add it to webpack.mix.js , like as you require (css, js, vue, sass, less):将它添加到webpack.mix.js ,就像你需要的一样(css、js、vue、sass、less):

mix.styles([
'resources/assets/css/my-arbitrary-style.css'
], 'public/css/all-css.css');

Note: If you copy a entire dir, like:注意:如果您复制整个目录,例如:

mix.copyDirectory('resources/assets/js/components', 'public/js/components');

... using watch webpack will copy your components directory as public/js/components/resources/assets/js/components . ...使用 watch webpack 会将您的组件目录复制为public/js/components/resources/assets/js/components

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM