Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@hzab/webpack-config
Advanced tools
webpack 相关核心配置
/**
* 用户自定义的 webpack 配置文件
* 注意:必须调用 mergeConfig,并传入 env
*/
const { resolve } = require("path");
const { mergeConfig } = require("@hzab/webpack-config");
module.exports = (env) =>
// 必须调用 mergeConfig,并传入 env
mergeConfig(
env,
// 用户自定义 webpack 配置
{
entry: "./src/index.tsx",
// module: {
// rules: [
// {
// test: /\.(md)$/i,
// type: "asset/resource",
// generator: {
// filename: "static/[name]_[hash][ext][query]",
// },
// },
// ],
// },
resolve: {
// 别名配置
alias: {
"@packages": resolve(__dirname, "./packages"),
"@": resolve("./example"),
"@assets": resolve("./example/assets"),
"@service": resolve("./example/services"),
},
},
devServer: {
port: 3000,
// 接口代理
// https://webpack.docschina.org/configuration/dev-server/#devserverproxy
proxy: {
// http://localhost:3000/api -> http://localhost:13000/api
"/api": "http://localhost:13000",
},
},
},
{
// 是否关闭多环境配置,关闭之后请直接使用 public/config/config.js 文件,public-config 下的文件将失效!
closeMulEnvConf: false,
// 关闭 mock 接口功能
closeMock: false,
// 是否关闭内部样式处理规则,使用自定义规则
closeStyleRules: false,
lessLoaderOptions: {
additionalData: `@import url(@/size.less);`,
},
},
);
属性名称 | 属性类型 | 必须 | 默认值 | 描述 |
---|---|---|---|---|
env | Object | 是 | webpack 环境变量 | |
userConf | Object | 否 | 用户自定义的 webpack 配置 | |
option | Object | 否 | 其他配置 |
| 属性名称 | 属性类型 | 必须 | 默认值 | 描述 | | ----------------- | -------------- | ---- | ------ | ------------------------------------------------------------------------------------------------- | --- | | closeMulEnvConf | boolean | 否 | false | 是否关闭多环境配置,关闭之后请直接使用 public/config/config.js 文件,public-config 下的文件将失效 | | splitCssFile | boolean | 否 | true | 是否拆分 css 文件到 css 文件夹,css/main.xxx.css。默认开启,传 false 关闭 | | | closeMock | boolean | 否 | true | 关闭 mock 接口功能 | | mockPort | number | 否 | 3100 | 自定义 mock 接口端口 | | mockPortAuto | boolean | 否 | | mock 接口端口自增 | | closeStyleRules | boolean | 否 | | 是否关闭内部样式处理规则,使用自定义规则 | | componentsMode | boolean/Object | 否 | | 是否使用组件模式,可配置对应的 entry 地址 localEntry、prodEntry | | | localConf | Object | 否 | | 运行时的 webpack 配置参数 | | | buildConf | Object | 否 | | 编译时的 webpack 配置参数 | | | lessLoaderOptions | Object | 否 | | less loader options 配置参数 | | | processEnv | Object | 否 | | 全局 process.env 参数 | | | filesystem | boolean | 否 | | 是否开启文件缓存 | | | filesystemConf | Object | 否 | | 文件缓存配置 | |
/**
* 用户自定义的 webpack 配置文件
* 注意:必须调用 mergeConfig,并传入 env
*/
const { resolve } = require("path");
const { mergeConfig } = require("@hzab/webpack-config");
module.exports = (env) =>
// 必须调用 mergeConfig,并传入 env
mergeConfig(
env,
// 用户自定义 webpack 配置
{
devServer: {
port: 3000,
// 接口代理
// https://webpack.docschina.org/configuration/dev-server/#devserverproxy
proxy: {
// http://localhost:3000/api -> http://localhost:13000/api
"/api": "http://localhost:13000",
},
},
},
{
processEnv: {
TTT_ENV: "TTT",
},
},
);
/**
* 用户自定义的 webpack 配置文件
* 注意:必须调用 mergeConfig,并传入 env
*/
const { resolve } = require("path");
const { mergeConfig } = require("@hzab/webpack-config");
module.exports = (env) =>
// 必须调用 mergeConfig,并传入 env
mergeConfig(
env,
// 用户自定义 webpack 配置
{
// 组件模式自行配置
output: {
library: "webpack_config", // 类库名称, 用下划线连接字符
},
resolve: {
// 别名配置
alias: {
// TODO: 本地开发测试,按需修改包名
"@hzab/list-render": resolve(__dirname, "../src"),
},
},
devServer: {
port: 3000,
},
},
{
// 选择组件模式,并配置对应的 entry
componentsMode: {
localEntry: "./example/index.tsx",
prodEntry: "./src/index.js",
},
// 是否关闭多环境配置,关闭之后请直接使用 public/config/config.js 文件,public-config 下的文件将失效!
closeMulEnvConf: true,
},
);
注意:该组件无需 build
修改版本号
命令:npm publish --access public
发布目录:
FAQs
webpack 相关核心配置
We found that @hzab/webpack-config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.