Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
AKFun 是一个基于 Webpack4.0 的打包工具,支持多种技术栈:Vue技术栈、React技术栈、React&TS技术栈(开发中)
全局安装AKFun,用于同时管理多个前端项目代码(可使用AKFun创建一个新项目)
$ yarn global add akfun 或者 npm i -g akfun
可选择项目类型:vue或者react,默认react类型的项目,也可通过--dir参数指定存放项目模板的目录
$ akfun init -t=vue
# 1、开启本地调试模式
$ akfun dev
# 2、构建生产环境代码
$ akfun build
# 3、构建第三方功能包
$ akfun build2lib
在现有项目中局部安装AKFun,给现有项目赋予AKFun的前端工程能力
$ yarn add akfun --dev 或者 npm i akfun --save-dev
打开package.json,在scripts中新增三条可执行命令
# 用于开启本地调试模式
"dev": "akfun dev"
# 用于构建生产环境代码
"build": "akfun build"
# 用于构建第三方功能包
"build2lib": "akfun build2lib"
开始构建当前项目
3.1 开启本地调试模式
$ npm run dev
3.2 构建生产环境代码
$ npm run build
3.3 构建第三方功能包
$ npm run build2lib
使用AKFun新建一个新项目
1.1 创建一个react项目
$ akfun init
1.2 创建一个vue类型项目
$ akfun init -t=vue
1.3 在指定的目录中创建一个新项目
$ akfun init -t=vue --dir=myTest1
创建AKFun的配置文件
$ akfun config init
关于AKFun提供三种构建场景
关于AKFun的配置文件
$ akfun config init
配置构建入口文件(webpack.entry)
关于多页面
关于多页面多模板
AKFun配置文件(akfun.config.js),以下使用AKFunConfig代表akfun.config.js配置对象
module.exports = {
settings: {
enableESLint: true, // 是否开启ESLint,默认开启ESLint检测代码格式
enableESLintFix: false, // 是否ESLint自动修正代码格式
enableStyleLint: true, // 是否开启StyleLint,默认开启ESLint检测代码格式
enableStyleLintFix: false // 是否需要StyleLint自动修正代码格式
},
...
}
以下是entry的配置位置,具体配置方法请查看Webpack官网 (关于entry的配置方法) 备注:建议以key/value形式(object { : string | [string] })配置entry
module.exports = {
...
webpack: {
entry: {
index: './src/index.js',
}
},
...
dev: {
entry: {}
}
build: {
entry: {}
}
build2lib: {
entry: {}
}
...
}
以下是extensions的配置位置,具体配置方法请查看Webpack官网 (关于resolve-extensions的配置方法)
module.exports = {
...
webpack: {
resolve: {
extensions: ['.js', '.jsx', '.vue', 'json'],
}
},
...
}
以下是alias的配置位置,具体配置方法请查看Webpack官网 (关于resolve-alias的配置方法)
module.exports = {
...
webpack: {
resolve: {
alias: {},
}
},
...
}
module.exports = {
...
webpack: {
template: '',
}
...
}
为项目中每个.scss后缀的样式文件注入公共的SASS内容(变量、mixin、function等)
module.exports = {
...
webpack: {
sassResources: [],
}
...
}
module.exports = {
...
envParams: {
common: { // 通用参数
'#version#': '20200810.1',
},
local: { // 本地开发环境
'#dataApiBase#': 'http://localhost:1024', // 数据接口根地址
'#assetsPublicPath#': 'http://localhost:1024', // 静态资源根地址
'#routeBasePath#': '/', // 路由根地址
},
}
...
}
module.exports = {
...
dev: {
proxyTable: {
},
}
...
}
8、用于开启本地调试模式的相关配置信息
module.exports = {
...
dev: {
NODE_ENV: 'development', // development 模式,不会启动UglifyJsPlugin服务
port: 80, // 启动server服务的端口
autoOpenBrowser: true, // 是否自动打开页面
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
assetsSubDirectory: '', // 资源引用二级路径
hostname: 'localhost', // 自动打开的页面主机
proxyTable: { // 接口代理
'/apiTest': {
target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
ws: true,
changeOrigin: true
}
},
cssSourceMap: false,
},
...
}
9、用于构建生产环境代码的相关配置信息
module.exports = {
...
build: {
NODE_ENV: 'production', // production 模式,会启动UglifyJsPlugin服务
assetsRoot: resolve('./dist'), // 打包后的文件绝对路径(物理路径)
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
assetsSubDirectory: '', // 资源引用二级路径
productionSourceMap: false, // 是否显示原始源代码
productionGzip: false, // 是否开启Gzip服务
productionGzipExtensions: ['js', 'css', 'json'], // Gzip识别的文件后缀
bundleAnalyzerReport: false, // 开启打包分析功能
}
...
}
10、用于构建第三方功能包的配置
module.exports = {
...
build2lib: {
NODE_ENV: 'production', // production 模式,会启动UglifyJsPlugin服务
libraryName: '', // 构建第三方功能包时最后导出的引用变量名
assetsRoot: resolve('dist'), // 编译完成的文件存放路径
assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
assetsSubDirectory: '', // 资源引用二级路径
productionSourceMap: false, // 是否显示原始源代码
productionGzip: false, // 是否开启Gzip服务
productionGzipExtensions: ['js', 'css', 'json'], // Gzip识别的文件后缀
bundleAnalyzerReport: false, // 开启打包分析功能
},
...
}
FAQs
前端脚手架:支持Vue技术栈和react技术栈
The npm package akfun receives a total of 15 weekly downloads. As such, akfun popularity was classified as not popular.
We found that akfun 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.