angular - 如何从特定捆绑文件名中删除哈希,在 Angular 10 中创建产品构建
问题描述
我正在尝试使用 angular 10 创建一个 chrome 扩展。在执行 ng build --prod 时,哈希被附加到 background.js 捆绑文件中,如“background.6f24e1b6d7ac365xxxxxx.js”。
有没有一种方法可以在执行 ng build --prod 时仅删除此捆绑包的哈希?
我可以做的一件事是使用自定义捆绑文件名 angular-cli中提到的节点重命名此文件。我希望通过 webpack 或任何其他方式来实现这一点。
custom.webpack.config文件(需要将 manifest.json 复制到 dist 文件夹并将 background.ts 转换为 background.js,因为它没有在 Angular 应用程序中使用)
const CopyWebPackPlugin = require('copy-webpack-plugin');
const path = require('path');
module.exports = {
plugins: [
new CopyWebPackPlugin({
patterns:[
{from:'manifest.json', to:''}
]
}),
]
entry: { background: 'src/background.ts' }
}
用于谷歌浏览器扩展的manifest.json文件
{
"name": "Javascript",
"version": "1.0",
"description": "javascript",
"key": <chrome extension key>,
"manifest_version": 2,
"browser_action": {
"default_popup": "signin.html"
},
"background": {
"scripts": [
"./background.js"
]
},
"permissions": [
"identity"
]
}
背景.ts文件
This will contain code for google chrome extension in typescript or javascript
注意:我只希望这两个包 runtime.js 和 background.js。我想在 main.xxxxxxxxxx.js、polyfills.xxxxxxxxxx.js、polyfills-es5.xxxxxxxxxx.js 等其他包中继续进行哈希处理。
解决方案
推荐阅读
- javascript - 有没有办法在 react native 中将 DrawerNavigator 的屏幕组件的功能访问到 DrawerNavigator 的菜单按钮中?
- android - Android Studio - 基本活动变成空活动
- ruby-on-rails - 如何停止返回异常html
- angular - 如何在 Angular v4.0 中使用 Snap.svg(错误:圆不是函数)
- javascript - 向对象添加属性
- python - 如何在熊猫中重新排列其他数据框中的列顺序
- ruby-on-rails - Rails:强制 SSL 会导致 Google Analytics 中的流量源丢失
- reactjs - Index.jsx 不会在状态更改时重新呈现
- c++ - 是否可以通过 getasynckeystate 使用存储在双字中的十六进制?
- multithreading - 互斥锁被 LOCKED 但预期的线程锁定