Angular “网页包”;拒绝应用传单中的样式。css“;
我用的是ngX火箭角8起动器。我想将此传单地图库包括在我的项目中: 我在index.html中包含了该文件Angular “网页包”;拒绝应用传单中的样式。css“;,angular,webpack,leaflet,Angular,Webpack,Leaflet,我用的是ngX火箭角8起动器。我想将此传单地图库包括在我的项目中: 我在index.html中包含了该文件 <link rel="stylesheet" type="text/css" href="./node_modules/leaflet/dist/leaflet.css" /> 我注意到没有webpack.config.js文件,所以我创建了一个,并放置: module.exports = { "module" : { loaders: [
<link rel="stylesheet" type="text/css" href="./node_modules/leaflet/dist/leaflet.css" />
我注意到没有webpack.config.js文件,所以我创建了一个,并放置:
module.exports = {
"module" : {
loaders: [
{ test: /\.css$/, loaders: [ 'style-loader', 'css-loader' ] }
]
}
};
我还输入了angular.json:
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"myproject": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/favicon.ico",
"src/apple-touch-icon.png",
"src/robots.txt",
"src/manifest.json",
"src/assets"
],
"styles": [
"src/main.scss",
"node_modules/leaflet/dist/leaflet.css"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
],
"serviceWorker": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"ci": {
"progress": false
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"hmr": true,
"hmrWarning": false,
"browserTarget": "myproject:build"
},
"configurations": {
"production": {
"hmr": false,
"browserTarget": "myproject:build:production"
},
"ci": {
"progress": false
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "myproject:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"scripts": [],
"styles": [
"src/main.scss",
"node_modules/leaflet/dist/leaflet.css"
],
"assets": [
"src/favicon.ico",
"src/apple-touch-icon.png",
"src/robots.txt",
"src/manifest.json",
"src/assets"
]
},
"configurations": {
"ci": {
"progress": false,
"watch": false
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"myproject-e2e": {
"root": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "myproject:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "myproject"
}
尽管我仍然在web控制台中看到错误。我要怎么做才能摆脱这个错误
我在index.html中包含了该文件,尝试将其添加到
样式
部分的angular.json文件中
<link rel="stylesheet" type="text/css" href="./node_modules/leaflet/dist/leaflet.css" />
"styles": [
"styles.css",
"./node_modules/leaflet/dist/leaflet.css"
],
您可以在这里找到更多信息:我已配置为使用scss,并已更新了OP以包含angular.json文件,尽管它仍然不起作用。你能检查一下我是否还需要做些什么吗?实际上我克隆了ngX Rocket angular 8 starter,并添加了“/node_modules/传单/dist/player.css”作为一种样式,并使其正常工作。不确定你的情况有什么问题。添加样式标记后是否停止服务器并重新构建?它应该在build部分