node-sass 生成sourcemap/监听文件

node-sass 生成sourcemap/监听文件

0.无关紧要的叨叨(可跳过)

遇到问题->>
不知道怎么用node-sass生成sourcemap文件,我本地的ruby环境下是可以直接生成的
这里写图片描述
但是现在做的项目就是要求把之前用ruby编译的saas文件全部改成用node-sass的,然后我以为只要在生成的css文件后加一个/*# sourceMappingURL=style.css.map */就好了,而且浏览器是可以看到定位到的.scss的(后来才发现是之前编译的map文件,难怪对不上号,点进去是空白0.0),网上找了好一会儿都没找到相关的命令,全是webpack或者ruby
,然后看了node-sass --help才解决,之前看help里有--source-map,没看到后面的内容有Emit source map (boolean, or path to output .map file),明明是很简单的东西,绕了一圈才解决,看来以后有问题要先看help


  Wrapper around libsass

  Usage:
    node-sass [options] <input.scss>
    cat <input.scss> | node-sass [options] > output.css

  Example: Compile foobar.scss to foobar.css
    node-sass --output-style compressed foobar.scss > foobar.css
    cat foobar.scss | node-sass --output-style compressed > foobar.css

  Example: Watch the sass directory for changes, compile with sourcemaps to the css directory
    node-sass --watch --recursive --output css
      --source-map true --source-map-contents sass

  Options
    -w, --watch                Watch a directory or file
    -r, --recursive            Recursively watch directories or files
    -o, --output               Output directory
    -x, --omit-source-map-url  Omit source map URL comment from output
    -i, --indented-syntax      Treat data from stdin as sass code (versus scss)
    -q, --quiet                Suppress log output except on error
    -v, --version              Prints version info
    --output-style             CSS output style (nested | expanded | compact | compressed)
    --indent-type              Indent type for output CSS (space | tab)
    --indent-width             Indent width; number of spaces or tabs (maximum value: 10)
    --linefeed                 Linefeed style (cr | crlf | lf | lfcr)
    --source-comments          Include debug info in output
    --source-map               Emit source map (boolean, or path to output .map file)
    --source-map-contents      Embed include contents in map
    --source-map-embed         Embed sourceMappingUrl as data URI
    --source-map-root          Base path, will be emitted in source-map as is
    --include-path             Path to look for imported files
    --follow                   Follow symlinked directories
    --precision                The amount of precision allowed in decimal numbers
    --error-bell               Output a bell character on errors
    --importer                 Path to .js file containing custom importer
    --functions                Path to .js file containing custom functions
    --help                     Print usage info

1.node-sass编译时生成sourcemap

node-sass --source-map map文件路径 sass文件路径 css文件路径

2. 监听整个文件夹 时生成sourcemap

node-sass --source-map map文件路径 --watch -r sass文件夹路径 -o css文件夹路径

3. 监听单个文件 时生成sourcemap

node-sass --source-map map文件路径 --watch sass文件夹路径 css文件夹路径

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值