Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@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,
// 允许 css module 和非 css module 共存,使用是否携带 module 后缀进行区别,如: xxx.module.(less|css) xxx.(less|css)
allowBothStyleModule: false,
// 是否关闭内部样式处理规则,使用自定义规则
closeStyleRules: false,
},
);
属性名称 | 属性类型 | 必须 | 默认值 | 描述 |
---|---|---|---|---|
env | Object | 是 | webpack 环境变量 | |
userConf | Object | 否 | 用户自定义的 webpack 配置 | |
option | Object | 否 | 其他配置 |
| 属性名称 | 属性类型 | 必须 | 默认值 | 描述 | | -------------------- | -------- | ---- | ------ | --------------------------------------------------------------------------------------------------------------- | --- | | closeMulEnvConf | boolean | 否 | false | 是否关闭多环境配置,关闭之后请直接使用 public/config/config.js 文件,public-config 下的文件将失效 | | closeMock | boolean | 否 | | 关闭 mock 接口功能 | | mockPort | number | 否 | 3100 | 自定义 mock 接口端口 | | mockPortAuto | boolean | 否 | | mock 接口端口自增 | | closeStyleRules | boolean | 否 | | 是否关闭内部样式处理规则,使用自定义规则 | | allowBothStyleModule | boolean | 否 | | 允许 css module 和非 css module 共存,使用是否携带 module 后缀进行区别,如:x.module.(less|css) x.(less| css) | | componentsMode | boolean/Object | 否 | | 是否使用组件模,可配置对应的 entry 地址 localEntry、prodEntry式 | |
/**
* 用户自定义的 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",
},
},
},
);
/**
* 用户自定义的 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 相关核心配置
The npm package @hzab/webpack-config receives a total of 3 weekly downloads. As such, @hzab/webpack-config popularity was classified as not popular.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.