# 其它功能配置
- 脚本入口扩展名配置
// cyb.config.js
module.exports = {
/**
* 页面入口脚本扩展名,可以改为.ts、.jsx等
*/
entryExt: '.js'
}
配置脚本扩展名需要cyb-cli版本 >= v1.5.0。
- 预处理由webpack打包的特殊标记的代码块
// cyb.config.js
module.exports = {
/**
* -------------------------------
* 侵入式mock配置
* /* @if MOCK */
* code...
* /* @endif */
*/
useMock: {
dev: false, // dev打包/* @if MOCK */与/* @endif */之间的代码块
dist: false // dist打包/* @if MOCK */与/* @endif */之间的代码块
}
}
用于代码侵入式的数据mock或者代码调试。
- 配置默认的图片压缩质量
// cyb.config.js
module.exports = {
imagemin: {
jpg: {
/**
* jpg图片压缩质量
*/
quality: 85
},
gif: {
/**
* gif图片压缩质量
*/
optimizationLevel: 1
},
png: {}
}
}
- 生产环境 html压缩配置
// cyb.config.js
module.exports = {
/**
* -------------------------------
* 生产环境 html压缩配置
* -------------------------------
*/
useHtmlMin: {
available: true,
/**
* 配置参考:
* https://github.com/kangax/html-minifier
*/
options: {
removeComments: true, //清除HTML注释
collapseWhitespace: true, //压缩HTML
collapseBooleanAttributes: true, //省略布尔属性的值 <input checked="true"/> ==> <input checked />
removeEmptyAttributes: true, //删除所有空格作属性值 <input id="" /> ==> <input />
removeScriptTypeAttributes: true, //删除<script>的type="text/javascript"
removeStyleLinkTypeAttributes: true, //删除<style>和<link>的type="text/css"
minifyJS: true, //压缩页面JS
minifyCSS: true //压缩页面CSS
}
}
}
- browsersync配置信息
// cyb.config.js
module.exports = {
/**
* -------------------------------
* browsersync配置信息
* -------------------------------
*/
browsersync: {
dev: {
available: true, // 研发环境是否开启浏览器自动化刷新
/**
* 配置参考:
* http://www.browsersync.cn/docs/options/
*/
options: {
port: 8080, // 研发环境 本地服务器的默认端口
startPath: "zindex.html"
}
},
test: {
/**
* 配置参考:
* http://www.browsersync.cn/docs/options/
*/
options: {
port: 8080, // 研发环境 本地服务器的默认端口
startPath: "zindex.html"
}
}
}
}