我在将 Angular 14 升级到 15 时遇到此构建错误。
我尝试添加 css 加载器,但没有成功
./node_modules/@ag-grid-community/styles/ag-grid.css?ngGlobalStyle:1:0 - Error: Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> .ag-icon {
| font-family: var(--ag-icon-font-family);
| font-weight: var(--ag-icon-font-weight);
package.json - 它的一部分
{
"dependencies": {
"@ag-grid-community/all-modules": "^27.3.0",
"@ag-grid-community/angular": "^31.0.1",
"@ag-grid-community/client-side-row-model": "^31.0.1",
"@ag-grid-community/core": "^31.0.1",
"@ag-grid-community/styles": "^31.0.1",
"@ag-grid-enterprise/all-modules": "^23.2.1",
"@ag-grid-enterprise/core": "^28.2.1",
"@ag-grid-enterprise/excel-export": "^31.0.1",
"ag-grid-angular": "^31.0.1",
"ag-grid-community": "^27.3.0",
"ag-grid-enterprise": "^27.3.0",
.
. and more
},
"devDependencies": {
"css-loader": "^6.8.1",
"typescript": "^4.9.5"
}
}
我也遇到同样的问题
cropperjs
./node_modules/cropperjs/dist/cropper.css:11:0 - Error: Module parse failed: Unexpected token (11:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
使用 Angular 14,我通过
angular.json
文件找到了解决方法:
...
"styles": [
"src/styles.scss",
"node_modules/cropperjs/dist/cropper.css"
],
...
但是这个解决方法不再起作用了