在ng构建期间修改javascript脚本标签的src位置 [英] Modify the src location for javascript script tags during ng build
本文介绍了在ng构建期间修改javascript脚本标签的src位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在构建后的index.html文件包含以下文件
My index.html file post ng build has the below files
<script type="text/javascript" src="inline.bundle.js"></script>
<script type="text/javascript" src="polyfills.bundle.js"></script>
<script type="text/javascript" src="styles.bundle.js"></script>
<script type="text/javascript" src="vendor.bundle.js"></script>
如何在src文件夹位置使cli前缀为'app',例如src="/app/vendor.bundle.js"
How can I make angular cli prepend 'app' in the src folder location, for example src="/app/vendor.bundle.js"
我需要进行上述更改,因为我是从'/app/'开头的文件系统位置将所有静态资产加载到dropwizard中的.
I would need to make the above change since I am loading all my static assets in dropwizard from a file system location starting with '/app/'
下面是我的angular-cli.json供参考
Below is my angular-cli.json for reference
angular-cli.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "web"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/font-awesome/css/font-awesome.min.css",
"../node_modules/primeng/resources/themes/ludvig/theme.css",
"../node_modules/primeng/resources/primeng.min.css",
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"defaults": {
"styleExt": "css",
"component": {}
}
}
推荐答案
angular-cli.json中有一个deployUrl
参数:
There is a deployUrl
parameter inside your angular-cli.json :
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "web"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"deployUrl": "/app/",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
您的进口将变为:
<script type="text/javascript" src="/app/inline.bundle.js"></script>
<script type="text/javascript" src="/app/polyfills.bundle.js"></script>
<script type="text/javascript" src="/app/styles.bundle.js"></script>
<script type="text/javascript" src="/app/vendor.bundle.js"></script>
这就是您想要的吗?
这篇关于在ng构建期间修改javascript脚本标签的src位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文