推荐一个基于 Vue.js 的 Seed-Project - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Kamato
V2EX    Vue.js

推荐一个基于 Vue.js 的 Seed-Project

  •  
  •   Kamato
    panteng 2015-10-28 17:29:22 +08:00 5542 次点击
    这是一个创建于 3634 天前的主题,其中的信息可能已经有所发展或是发生改变。

    vue-gulp-sass-browserify-boilerplate

    Logos

    一个使用 Vue.js , Gulp , Sass , Browserify 的前端模板。

    如何使用

    1. 安装 Sass.
    2. 安装 Node.js.
    3. 为你的浏览器安装 Livereload 插件。
    4. 在命令行中运行 npm install,安装 node 模块
    5. 在命令行中运行 bower install,安装 bower 组件
    6. 在命令行中运行 gulp ,搞定了~

    文件树结构

    app/ --> Source files for the application. css/ --> Stylesheets folder. src/ --> Sass files. main.scss --> Primary Sass file. dist/ style.css --> Css file compiled from Sass. img/ --> Images. logo.png --> Logo of Vue.js, used for favicon. js/ --> Javascripts folder. src/ --> Source files for the MVVM part (Vue.js). components/ --> Components. view1/ --> The view1 component template and logic. template.html --> The partial template. index.js --> The controller and model logic. view2/ --> The view2 component template and logic. template.html --> The partial template. index.js --> The controller and model logic. directives/ --> Custom directives. my-frist-directive/ --> A demo directive. index.js --> Logic for the directive. filters/ --> Custom filters. my-first-filter/ --> A demo filter. index.js --> Logic for the filter. app.html --> Templates for the main application. app.js --> Main appliaction module. main.js --> Entry point file for browserify. Initialize Vue instance, routes, custom directives and filters. dist/ bundle.js --> Generated by browserify from the files in js/src folder. bundle.min.js --> The uglified version of bundle.js. index.html --> App layout file. .bowerrc .gitignore bower.json gulpfile.js --> Gulp tasks. logos.png package.json README.md 

    Gulp 任务

    1. compile-css 将 Sass 编译为 style.css
    2. minfiy-css 压缩 style.css 为 style.min.css
    3. bundle 使用 Browserify 将所有 vue 相关的文件整合打包为 bundle.js
    4. uglify-js 压缩 bundle.js 为 bundle.min.js
    5. watch 监控文件改动,并自动执行对应任务,如刷新浏览器
    6. default 运行 compile-sassbundlewatch任务。
    7. compress 运行 minify-cssuglify-js任务。

    FAQ

    1. 为什么使用 gulp-ruby-sass 而不使用依赖更少的 gulp-sass ?

      Gulp-sass 的安装依赖于 node-gyp ,而在 Windows 系统中想让 node-gyp 正常工作要花费很多精力。 Gulp-ruby-sass 不依赖于 node-gyp 而依赖于 Sass , Sass 又依赖于 Ruby ,不过在 Windows 上安装 Sass 和 Ruby 还是很简单的。

    如果你是在 OSX 或 Linux 下开发,那么你可以选择使用 gulp-sass 。

    1. 为什么使用 live-reload 而不使用不需要安装插件的 browserSync?

      原因同问题 1 。 BrowserSync 依赖于 node-gyp 。

    Lisence

    MIT

    第 1 条附言    2015-10-28 18:04:57 +08:00
    4 条回复    2015-11-29 11:06:25 +08:00
    banri
        1
    banri  
       2015-10-28 17:35:14 +08:00
    Windows 下编译 Sass 是有坑的,需要以下设置:

    进入 Ruby22-x64\lib\ruby\gems\2.2.0\gems\sass-3.4.15\lib\sass ,打开 engine.rb 文件,找到各种 require... 在它们的下方添加一行:
    Encoding.default_external = Encoding.find('utf-8')
    Kamato
        2
    Kamato  
    OP
       2015-10-28 17:39:52 +08:00
    @banri 是编码的问题吗?我一般会在每个.scss 文件中添加一行 @charset "utf-8";,目前没遇到过你说的坑。
    Kamato
        3
    Kamato  
    OP
       2015-10-28 17:49:55 +08:00
    NemoAlex
        4
    NemoAlex  
       2015-11-29 11:06:25 +08:00
    谢谢分享。
    最近也在整理一个类似的东西,区别是只用 NPM ,不用 bower 和 browserify ,不考虑使用 Windows 的开发者。
    过两天发布。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     854 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 30ms UTC 21:41 PVG 05:41 LAX 14:41 JFK 17:41
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86