我使用的是Laravel 8PHP框架,我需要使用node在 localhost 上编译JS和CSS文件。当我尝试运行npm run dev
时,错误输出为:
$ npm run dev
> dev
> npm run development
> development
> mix
[webpack-cli] AssertionError [ERR_ASSERTION]: mix.combine() requires a full output file path as the second argument. Got C:\xampp\htdocs\project\public\css
at Function.combine (C:\xampp\htdocs\project\node_modules\laravel-mix\src\Assert.js:54:9)
at Combine.addTask (C:\xampp\htdocs\project\node_modules\laravel-mix\src\components\Combine.js:49:16)
at Combine.register (C:\xampp\htdocs\project\node_modules\laravel-mix\src\components\Combine.js:29:14)
at Object.components.<computed> [as styles] (C:\xampp\htdocs\project\node_modules\laravel-mix\src\components\ComponentRegistrar.js:163:49)
at Object.<anonymous> (C:\xampp\htdocs\project\webpack.mix.js:17:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
我怎么能看出来,问题出在mix
文件中,语法错误会是问题吗?
"这是代码"
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js')
.js('resources/assets/js/bootstrap.js', 'public/js')
.js('resources/assets/js/core.min.js', 'public/js')
.js('resources/assets/js/script.js', 'public/js')
.js('resources/assets/js/slider.js', 'public/js')
.js('resources/assets/js/html5shiv.min.js', 'public/js')
.js('resources/assets/js/jquery-3.6.0.min.js', 'public/js')
.js('resources/assets/js/pointer-events.js', 'public/js');
mix.styles([
'resources/assets/css/bootstrap.css',
'resources/assets/css/bootstrap-grid.css',
'resources/assets/css/bootstrap-utilities.css'
],'public/css');
mix.styles([
'resources/assets/css/app.css',
'resources/assets/css/util.css'
], 'public/css');
为此,我使用Laravel 7 Docs,因为我在Laravel 8 Docs中找不到任何内容
我没有使用sass或scss,因为源项目的每个文件都有~30000css行,我不知道如何转换它。
以下是package.json
文件
{
"dependencies": {
"bootstrap-icons": "^1.7.2",
"cross-env": "^7.0.3",
"laravel-mix": "^6.0.39"
},
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
}
}
1条答案
按热度按时间kg7wmglp1#
你必须传递一个文件作为第二个参数,而不是文件夹。所以: