Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript “当我更新时样式加载器停止工作”@角度devkit/build angular“;_Javascript_Angular_Angular6_Angular8_Webpack Style Loader - Fatal编程技术网

Javascript “当我更新时样式加载器停止工作”@角度devkit/build angular“;

Javascript “当我更新时样式加载器停止工作”@角度devkit/build angular“;,javascript,angular,angular6,angular8,webpack-style-loader,Javascript,Angular,Angular6,Angular8,Webpack Style Loader,我在angular8工作,面临一个问题 为了动态加载我的样式,我使用了下面的代码,它工作正常,但是当我将包“@angular defect/build angular”:“^0.800.0”更新为“@angular defect/build angular”:“^0.803.21”,它就停止工作了。应用程序工作正常,终端和浏览器控制台中没有错误,但应用程序上没有实现样式 声明函数require(名称:string):任意; 恩戈尼尼特(){ 需要('style-loader!。/file-pat

我在angular8工作,面临一个问题

为了动态加载我的样式,我使用了下面的代码,它工作正常,但是当我将包
“@angular defect/build angular”:“^0.800.0”
更新为
“@angular defect/build angular”:“^0.803.21”
,它就停止工作了。应用程序工作正常,终端和浏览器控制台中没有错误,但应用程序上没有实现样式

声明函数require(名称:string):任意;
恩戈尼尼特(){
需要('style-loader!。/file-path');
}
package.json

{
"name": "latest-frontend-theme",
"version": "0.0.0",
"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json"
},
"private": true,
"dependencies": {
    "@agm/core": "^1.1.0",
    "@angular/animations": "^8.2.14",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "~8.2.14",
    "@angular/compiler": "~8.2.14",
    "@angular/core": "~8.2.14",
    "@angular/forms": "~8.2.14",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "~8.2.14",
    "@angular/platform-browser-dynamic": "~8.2.14",
    "@angular/router": "~8.2.14",
    "@ngx-loading-bar/core": "^4.2.0",
    "@ngx-loading-bar/router": "^4.2.0",
    "angular2-text-mask": "^9.0.0",
    "crypto-js": "^3.1.9-1",
    "file-saver": "^2.0.2",
    "moment": "^2.24.0",
    "mydatepicker": "^2.6.8",
    "ng2-ckeditor": "^1.2.6",
    "ng2-file-upload": "^1.3.0",
    "ng6-toastr": "^6.0.0",
    "ngx-google-places-autocomplete": "^2.0.4",
    "ngx-slick": "^0.2.1",
    "rxjs": "~6.5.3",
    "rxjs-compat": "^6.5.3",
    "tslib": "^1.9.0",
    "zone.js": "~0.10.2"
},
"devDependencies": {
    "@angular-devkit/build-angular": "~0.803.21",
    "@angular/cli": "~8.3.21",
    "@angular/compiler-cli": "~8.2.14",
    "@angular/language-service": "~8.2.14",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.8",
    "@types/node": "~12.12.21",
    "codelyzer": "^5.2.1",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~8.5.4",
    "tslint": "~5.20.1",
    "typescript": "~3.4.3",
    "webpack-bundle-analyzer": "^3.6.0"
}
}


任何类型的帮助都是值得的。

我今天遇到了同样的问题,仍然无法使用
样式加载器找到解决方案,因此我提出了另一种解决方案,我将与大家分享,因为这仍然没有答案

我以前使用的
样式加载器是这样的:

//在AppComponent中
私有初始化主题(设置:设置){
if(settings.style){
//设定特定主题
require(`style loader././../src/${settings.style.id}-theme.scss`);
}
否则{
require(`style loader././../src/default theme.scss`);
}
}
我的解决方案是更新此函数以手动应用样式表(作为已处理的CSS文件),如下所示:

//在AppComponent中
私有初始化主题(设置:设置){
常量applyStyleSheet=(样式名:字符串)=>{
const head=document.getElementsByTagName('head')[0];
const style=document.createElement('link');
style.rel='stylesheet';
style.href=`${styleName}.css`;
头。附属物(样式);
};
if(settings.style){
//设定特定主题
applyStyleSheet(`${settings.style.id}-theme`);
}
否则{
applyStyleSheet(`default theme`);
}
}
为了处理SCSS文件,我更改了我的
angular.json
文件,在选项中添加了
extractCss

“选项”:{
“提取CSS”:正确
...
}
。。。以及在
样式
数组中指定要处理但不注入的每个SCSS文件:

“样式”:[
{
“输入”:“src/default theme.scss”,
“bundleName”:“默认主题”,
“注入”:错误
},
{
“输入”:“src/basic theme.scss”,
“bundleName”:“基本主题”,
“注入”:错误
}
...
]

请发布
package.json
?我已经更新了问题并发布了package.json文件。首先尝试两件事,停止angular应用程序,退出vs代码,然后启动vs代码,然后再次运行angular应用程序。之后请更新这里。你能解释什么是“vs代码”吗?你的IDE是什么,我假设它是visual studio代码?