gpt4 book ai didi

webpack - 有没有办法同时观看两个 Laravel Mix Webpack 配置文件的任何更改?

转载 作者:行者123 更新时间:2023-12-04 15:25:46 25 4
gpt4 key购买 nike

使用 Laravel Mix,是否可以通过一个命令查看两个 Webpack 配置文件,以便对任何底层文件的更改立即导致编译必要的文件?

具体来说,我有以下两个与 Laravel Mix 一起使用的 Webpack 配置文件:webpack.css.mix.jswebpack.js.mix.js
然后我在 scripts 中有以下命令package.json 的对象:

"development-css": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --watch --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.css.mix",
"development-js": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --watch --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.js.mix",
"watch": "npm run development-css -- --watch & npm run development-js -- --watch",
npm run watch command 只监视指定的第一个命令。在上述情况下,我保存到 Sass 文件的任何更改都会生成,但不会更改任何 JS/Vue 文件。如果我切换 watch 中的两个命令命令,那么 JS 将基于更改/保存,而不是 Sass。

有没有人知道如何构建 npm run watch命令(或底层命令),以便我可以同时观看 Sass 和 JS?

此外,对于它的值(value),由于目前 Laravel Mix 中的一个错误,我不得不将 Sass 和 JS 编译分成两个单独的文件。此错误记录在此处: https://github.com/JeffreyWay/laravel-mix/issues/1914

讨论确实解决了错误,但没有解决如何将两个命令合并为一个监视命令。谢谢你。

最佳答案

更新2 :这里有一个要点:
https://gist.github.com/Jossnaz/7cf182e794e515d068159ad71fcf7855
基本上为js文件运行yarn hot,为tailwind文件运行yarn watch。似乎工作
更新 :
相关,不完全是问题 ,但与关注有关(具有多个混合构建)
实际上有一个 github 项目可以解决类似的问题:
https://github.com/omnichronous/multimix
不回答 afaik,同时构建两者。没试过,有兴趣的就离开这里
旧答案
代表@HartleySan 回答

@rmondesilva was suggesting that without concurrently one of the two commands is not working. I installed it without trying other solutions and it has worked.

npm install concurrently --save-dev

I'm using two config files (webpack.mix.js and webpack.mix.css.js), and this is the relevant part of my package.json:

"scripts": {
"css-dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --env.mixfile=webpack.mix.css --config=node_modules/laravel-mix/setup/webpack.config.js",
"js-dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"development": "concurrently \"npm run css-dev\" \"npm run js-dev\"",
"css-watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --watch --hide-modules --env.mixfile=webpack.mix.css --config=node_modules/laravel-mix/setup/webpack.config.js",
"js-watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --watch --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "concurrently \"npm run css-watch\" \"npm run js-watch\"",
"watch-poll": "npm run watch -- --watch-poll",
"css-production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --env.mixfile=webpack.mix.css --config=node_modules/laravel-mix/setup/webpack.config.js",
"js-production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "concurrently \"npm run css-production\" \"npm run js-production\"",
"dev": "npm run development",
"prod": "npm run production"
}

Last two ones are obviously just aliases, and I don't believe I have ever used watch-poll.

(I'm also using mergeManifest() in the two webpack.mix configuration files).



https://github.com/JeffreyWay/laravel-mix/issues/1914#issuecomment-642218920

关于webpack - 有没有办法同时观看两个 Laravel Mix Webpack 配置文件的任何更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62288513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com