相关疑难解决方法(0)

如何设置webpack来缩小和组合scss和javascript,如CodeKit?

我在使用webpack而不是Codekit v1.9.3时遇到了麻烦.我开始努力从CodeKit转移到Grunt和Gulp,然后了解webpack哪些听起来非常酷.我似乎无法让它正常工作.

"像Codekit"意味着我可以:

  • javascriptcoffeescript语法写
  • 将所有脚本源文件和库缩小/缩小并合并到一个文件中
  • bootstrap-sass根据需要选择性地包括(scss)框架的组件
  • 通过sass变量维护一个带有引导程序自定义的小文件,比如 $brand-primary
  • 用于webpack --watch在更改脚本和样式时自动编译它们
  • 最终得到一个css文件和一个可以包含在样式表和脚本标记中的脚本文件.

Codekit项目设置

凉亭资源:

我目前正在全球范围内存储这些项目:

~/bower_components/twbs-bootstrap-sass/vendor/assets/stylesheets
Run Code Online (Sandbox Code Playgroud)

因为CodeKit支持指南针,我在我的config.rb文件中有这个:

add_import_path "~/bower_components/twbs-bootstrap-sass/vendor/assets/stylesheets"
Run Code Online (Sandbox Code Playgroud)

项目结构

js/fancybox.js
js/main.js               <-- currently the compiled js 'output' file
js/main.coffee

css/styles.css           <-- currently the compiled css 'output' file

scss/styles.scss
scss/modules/_bootstrap-customizations.scss
scss/modules/_typography.scss
scss/partials/_header.scss
scss/partials/_footer.scss
Run Code Online (Sandbox Code Playgroud)

styles.scss的内容

@import "modules/bootstrap-customizations";  # local customizations
@import "bootstrap/variables";
@import "bootstrap/mixins";
...                                          # load bootstrap files as required
@import "bootstrap/wells";
Run Code Online (Sandbox Code Playgroud)

系统设置:

  • system:OS X 10.9
  • 节点 - v0.10.32 …

sass coffeescript npm webpack

32
推荐指数
1
解决办法
3万
查看次数

标签 统计

coffeescript ×1

npm ×1

sass ×1

webpack ×1