Webpack Subresource Integrity 项目教程

Webpack Subresource Integrity 项目教程

webpack-subresource-integrityWebpack plugin for enabling Subresource Integrity.项目地址:https://gitcode.com/gh_mirrors/we/webpack-subresource-integrity

1. 项目的目录结构及介绍

webpack-subresource-integrity/
├── examples/
├── lib/
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
└── yarn.lock
  • examples/: 包含项目的示例代码。
  • lib/: 包含项目的主要代码文件。
  • .gitignore: 指定Git版本控制系统忽略的文件和目录。
  • .npmignore: 指定npm发布时忽略的文件和目录。
  • LICENSE: 项目的许可证文件。
  • README.md: 项目的说明文档。
  • package-lock.json: 锁定npm依赖包的版本。
  • package.json: 项目的配置文件,包含依赖、脚本等信息。
  • yarn.lock: 锁定yarn依赖包的版本。

2. 项目的启动文件介绍

项目的启动文件主要是 package.json 中的 scripts 部分。以下是一个示例:

{
  "scripts": {
    "test": "yarn run lint && yarn run test:unit && yarn run test:integration && yarn run test:examples",
    "lint": "eslint .",
    "test:unit": "jest --coverage",
    "test:integration": "jest --config jest.integration.config.js",
    "test:examples": "jest --config jest.examples.config.js"
  }
}
  • test: 运行所有测试,包括单元测试、集成测试和示例测试。
  • lint: 运行代码风格检查。
  • test:unit: 运行单元测试并生成覆盖率报告。
  • test:integration: 运行集成测试。
  • test:examples: 运行示例测试。

3. 项目的配置文件介绍

项目的配置文件主要是 package.jsonwebpack.config.js(如果存在)。以下是 package.json 的部分配置:

{
  "name": "webpack-subresource-integrity",
  "version": "5.1.0",
  "description": "Webpack plugin for enabling Subresource Integrity",
  "main": "lib/index.js",
  "repository": {
    "type": "git",
    "url": "https://github.com/waysact/webpack-subresource-integrity.git"
  },
  "keywords": [
    "webpack",
    "html-webpack-plugin",
    "sri",
    "subresource-integrity"
  ],
  "author": "waysact",
  "license": "MIT",
  "dependencies": {
    "html-webpack-plugin": "^5.0.0"
  },
  "devDependencies": {
    "eslint": "^7.0.0",
    "jest": "^26.0.0"
  }
}
  • name: 项目名称。
  • version: 项目版本。
  • description: 项目描述。
  • main: 项目的主入口文件。
  • repository: 项目的仓库地址。
  • keywords: 项目的关键词。
  • author: 项目作者。
  • license: 项目许可证。
  • dependencies: 项目依赖的其他包。
  • devDependencies: 开发环境依赖的其他包。

如果项目中包含 webpack.config.js,它通常包含Webpack的配置信息,例如入口文件、输出目录、加载器和插件等。以下是一个示例:

const WebpackSubresourceIntegrity = require('webpack-subresource-integrity');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'bundle.js',
    path: __dirname + '/dist',
    publicPath: '/',
  },
  plugins: [
    new WebpackSubresourceIntegrity({
      hashFuncNames: ['sha256'],
    }),
  ],
};
  • entry: 指定Webpack的入口文件。
  • output: 指定Webpack的输出文件和目录。
  • plugins: 配置Webpack插件,这里使用了 webpack-subresource-integrity 插件。

以上是 webpack-subresource-integrity

webpack-subresource-integrityWebpack plugin for enabling Subresource Integrity.项目地址:https://gitcode.com/gh_mirrors/we/webpack-subresource-integrity

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

苗眉妲Nora

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值