o2team / athena Goto Github PK
View Code? Open in Web Editor NEWO2前端流程工具
Home Page: https://athena.aotu.io/
License: MIT License
O2前端流程工具
Home Page: https://athena.aotu.io/
License: MIT License
目前 widget 的 json 文件有一个 data 字段,但是好像还没有什么作用。
是否考虑可以在 data 中设置组件需要的默认值,调用组件时,把预设值的默认值与传入的参数进行合并,然后提供给组件使用。 :)
// widget.html
<h4><%= hello %> <%= name %>!</h4>
// widget.json
{
...
data: {
"hello": "hello",
"name": "world"
}
}
//main.html
<%= widget.load('widget', {name: "adam"}) %> // <h4>hello adam!</h4>
目前新建的page 只能是html,手动把它后缀改成shtml 编译时也不会被解析,希望改进下,使得新建page 时类型可选shtml 文件,以及本地服务器增加处理sinclude 语句的能力,以方便本地开发调试。
版本:[email protected]
出错命令:ath app
出错信息
Allo xxxx! 我要开始创建项目了哟~
need help? go and open issue: https://github.com/o2team/athena/issues/new
undefined:1
^
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse ()
at Request._callback (/usr/local/lib/node_modules/athena-html/lib/create/base.js:232:25)
at Request.self.callback (/usr/local/lib/node_modules/athena-html/node_modules/request/request.js:187:22)
at Request.emit (events.js:182:13)
at Request. (/usr/local/lib/node_modules/athena-html/node_modules/request/request.js:1126:10)
at Request.emit (events.js:182:13)
at IncomingMessage. (/usr/local/lib/node_modules/athena-html/node_modules/request/request.js:1046:12)
at Object.onceWrapper (events.js:273:13)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
当引用雪碧图中不存在的文件的时候,会报:
error schoolopen/dist/_/static/sass/page.scss (/Library/Ruby/Gems/2.0.0/gems/compass-core-1.0.3/lib/compass/core/sass_extensions/functions/image_size.rb:31:in `get_size_for_png': undefined method `unpack' for nil:NilClass)
当把这个文件补上以后,依然报错,并且不能正常生成雪碧图 ( 0 bytes )
目前解决方案是,把原来的雪碧图删除,重新生成
看有没有别的方案可以自动 fix
[20:07:46] 开始编译模块live_cia!
[20:07:46] 开始扫描live_cia模块所有文件!
undefined
Error: Can't load the addon. Issue to: https://github.com/xiangshouding/node-pngquant-native/issues
at Object.<anonymous> (/usr/local/lib/node_modules/athena-html/node_modules/athena-png-native/node-pngquant-native/binding.js:66:7)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
at Module.load (module.js:490:32)
at tryModuleLoad (module.js:449:12)
at Function.Module._load (module.js:441:3)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/athena-html/node_modules/athena-png-native/node-pngquant-native/index.js:1:77)
at Module._compile (module.js:573:32)
at Object.Module._extensions..js (module.js:582:10)
[20:07:46] 预览live_cia模块...
貌似是 node-pngquant-native
这个库的问题,没有往下追...
只是建一个空的模块,已经build过了,而且正常,就是在serve时出错, node 提示:
tasks/styles.js:95行
var filename= item.match[1] typeError: can not read property '1' of null,求解~~~
watch到目录的改动,最好让做所有的命令操作时不需要中断watch
如果模板里用到了一个未传入的变量,如 <%= username || 'visitor' %>
,会报 ReferenceError: username is not defined 的错误,望修复,谢谢!
使用 element ui的时候,需要实现按需引入
需要修改 .babelrc ,和增加 babel-plugin-component 插件
这个需要如何配置,按照文档没有看明白
我是这样引入的
static-conf.js
module.exports = {
staticPath: {
'common.css': [
'static/less/index.less'
]
}
};
然后
<%= getCSS('static/less/index.css') %>
这套开发流程可以兼容react吗?我觉得这种做法对项目侵入性比较大,有没有轻巧的,可以对接其他项目的,比如react vue
感谢凹凸团队开源这么好用的前端流程工具谢谢!这里有一些使用建议:构建模块的时候,控制台会有一些中文提示,建议改成英文的,嘿嘿,毕竟咱们也是一个国际化的团队,嘿嘿。提示文字是够可以简单严肃一点,每次使用的时候都会笑场,囧。。。一些薄见,还请海涵。谢谢!
图片不压缩的配置可否支持一下 正则匹配。图片一多,要一个一个地写到配置文件中去太麻烦了。
更新时添加进度条反馈,可以知道更新情况
如果在项目存在backbone,jq这些框架的时候,要怎么处理?
sass雪碧图合并函数:
// 雪碧图合并
// $name:[雪碧图名称]
// $img:[图标文件名]
// $rem:[单位]rem/px
// $rootvalue:[如果是rem需要指定一个rootvale值]
// 使用:@include as('halo', 'icon_halo'); 或 @include as('halo', 'icon_halo', rem);
@mixin as($name:sprite,$img:'',$rem: 'px', $rootvalue: 20){
@if($rem!='rem'){
$rem: 'px';
}
@if($rem=='rem'){
$rem: 'rem=#{$rootvalue}';
}
@if(''!=$img){
background: url(images/#{$img}@2x.png?__sprite=#{$name}&__#{$rem});
}
}
我们通过这样调用
@include as("icon", "p1_btn", "rem");
@include as("icon", "p1_btn", "px");
生成出来的雪碧图,只会选择一种单位,而我需要两种单位
或
@include as("page", "p1_btn", "rem");
@include as("icon", "p1_btn", "px");
生成出来的雪碧图,只会选择其中一个,且只选择一种单位,而我需要是要两张雪碧图,两种单位
组件在创建时是基于module创建的,但是在打包合并的时候,却是基于页面去区分的。
也就是公共组件会在不同页面里被重复引用并且分别打包,有点迷
是否应该把公共组件打包到static里面去?
static下的图片名称和page下的图片名称不能重复,可以加上hash或者id做区分
在不同的模块和组件中的less文件需要引入gb/static/目录下全局的common.less,但是当前在less中引入common.less的话,路径只在当前的模块路径下面寻找,应该怎么配置才能让gb/static/less/目录下的全局的less生效
执行ath s后,log最后如下:
[14:14:11] 开始tuan模块任务styles!
[14:14:12] gulp-postcss: buy.css
然后无错误退出,在其它机器上正常使用
node: 10.3.0 (nvm管理)
npm:6.1.0
athena-html:1.4.14
.pipe($.if(isServe, athenaMate.plumber())) // 删除这行正常,进一步排查这个函数
我的疑问是在93行中,每次执行pipe2的时候已经会重新patchPipe了,这里为什么在pathPipe函数中还要监听重新patch一次?
module-conf.js
fontcompress : {
enable: true
},
project/index.less
@font-face {
font-family: 'benmoxueyuan';
src: url('benmoxuaeyuan.ttf');
font-weight: normal;
font-style: normal;
}
.main {
font-family: 'benmoxueyuan';
width: 100%;
margin-top: 50px;
font-size: 25px;
}
提示在gb目录下找不到fonts文件夹内字体
目前版本,compress 选项已经默认在 module-conf.js 上显示了。不过,原来的 transform 压缩问题仍未得到解决。麻烦在下一个版本使用以下配置:
compress: {
css: {
mergeRules: false,
mergeIdents: false,
reduceIdents: false,
discardUnused: false,
minifySelectors: false,
reduceTransforms: false
},
js: {
mangle:{except : ['require', 'exports', 'seajs', 'module']}
}
},
athena 开启server模式的时候 通过webstorm复制文件到对应的page目录 会导致假死 而且进程杀不掉..只能重启电脑才能继续开发
win7,nodejs:8.11.4
更正: 好像不仅仅是webstorm的复制 我通过win7的资源管理器去复制图片文件,然后使用webstorm的sync刷新一下webstorm目录 接着这个Athena直接死掉 nodejs也关闭不掉。。
目前?__inline功能主要是针对图片的,可以尝试扩展,对xx.ttf、xx.svg等字体文件直接转换为base64,从而解决跨域,减少请求的问题
我在写业务时会引入几个库如:
<%= getJS('tweenjs-0.6.2.min.js') %>
<%= getJS('preloadjs-0.6.2.min.js') %>
<%= getJS('easeljs-0.8.2.min.js') %>
<%= getJS('soundjs-0.6.2.min.js') %>
<%= getJS('zepto.min.js') %>
<%= getJS('zepto.animation.js') %>
<%= getJS() %>
因为我不想库文件被转换了所以在配置时排除
useBabel: {
enable: true,
jsxPragma: 'Nerv.createElement', // jsx转换支持,默认为 React.createElement
exclude: [ // 排除掉不需要转义的文件
'static/js/easeljs-0.8.2.min.js',
'static/js/preloadjs-0.6.2.min.js',
'static/js/soundjs-0.6.2.min.js',
'static/js/tweenjs-0.6.2.min.js',
'static/js/zepto.animation.js',
'static/js/zepto.min.js',
]
},
然后用 ath s 启动服务,但当我修改业务代码,保存后发现以上库文件都会报错,
应该是被babel修改了。
现在貌似对json文件过滤了,但是pixi框架使用雪碧图的一种方式是通过json加载雪碧图信息,所以需要针对json里请求的图片地址的图片资源自动发布,看看这个能不能解决下?
图片添加MD5之后也是一样的问题,会生成两份,感觉这样好像没必要呀,
给各较完整的展示页,现在的项目新建出来都是基本空空的。
今天发现 widget 中的 js 使用函数嵌套函数会报错:
_.merge([], _list.splice(5,1), list)
SyntaxError: missing ) after argument list
当页面引用自建的 main.scss 文件,在 main.scss 改动时,页面会刷新并载入新样式,
但是当在 main.scss 文件中 import 另外一个自建样式文件,如 other.scss,当修改 other.scss 文件时,页面有刷新,但是并没有编译载入新的样式,而是需要在 main.scss 改变时才重新编译出新样式
npm install -g athena-html
安装后仅有新建模块pages之类的,此rep是否含有可视化资源管理平台,请指教。
athena 的雪碧图片能否扩展一下或是出些新的API。目前有两个场景用不了:js(canvas)的素材雪碧图; css中非background的雪碧图(专指mask)
build 生成的 css 文件计算 hash 时没有计算图片资源的文件名中的 hash,导致更新图片后,图片 hash 改变,但是 css 文件 hash 并没有更新
static的资源名字中带多个点的不能被引用到,改成下划线就行了,比如:<%= getJS('zepto.detect.js', 'gb') %> 没有引进来,当把文件名以及static-conf.js中的配置名字都改成下划线形式 zepto_detect.js
就正常了
widget load的时候,把gb路径的sass也抓下来到当前模块中了,可以判断当前项目的gb里是否有同名文件,然后选择不下载那个sass,或把那个sass塞到gb里么?
处理icons时,一般都是切图、写sass,遇到icon(最近的一个项目130个icon)比较多的情况下比较花时间去写这部分sass,不知道雅典娜能不能提供自动合并_icons.scss的功能,通过@import引入自动合并好的样式文件。比如:images/icons/aaa.png,images/icons/bbb.png,images/icons/bbb_disabled.png,自动监控文件增删,自动合并为_icons.scss :
$icons: sprite-map("icons/*.png", $spacing:10px);
.aaa {
display: inline-block;
@include s2b($icons, "aaa");
}
.bbb {
display: inline-block;
@include s2b($icons, "bbb");
&_disabled {
@include s2b($icons, "bbb_disabled");
}
}
这样就省略了“手写雪碧图css”的步骤。
这些icon的css不包含其他属性,如果需要其他属性还要在另外的css文件里写。
当然这些sass是用compass的sprite-map,用“__sprite”也是可以的
最近使用 athena 的 合并雪碧图功能,突然爱上了这个功能。在想,athena 如果可以把 webp 转换的功能也加上去就好了。可以使用 ?__webp 的参数功能来实现。
例如:
img{background-image: url(1.png?__webp);}
雅典娜帮我自动把 1.png 转化成 1.webp,然后再把上面的代码转生成:
img{background-image: url(1.png);}
.webp img{background-image: url(1.webp);}
这样子我可以结合 js 做 webp 支持判断,如果支持在 html 的 root 节点上添加一个 webp的类名。
添加的自定义组件可以继承已有组件,并进行自定义,或者在组件中添加钩子,可以自定义组件部分内容
https://github.com/o2team/athena#资源定位
这里提到了使用 __uri 可以自动化将资源引用链接替换成配置好的目标地址
。我的理解是引用 __uri(1.jpg) 后,athena 会自动帮我把引用的hash化后的资源 1_xxxxxxxx.jpg。然而,我的实际操作结果是,__uri后的图片是 1.jpg,也就是 __uri 没起到作用?
------我是在js中使用 __uri()。html的<%= __uri() %> 还未尚试
可以配置为静态资源添加版本号,以便于强制刷新 IDC 资源
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.