css SASS:如何删除/*#源MapURL注解

vvppvyoh  于 2023-03-05  发布在  其他
关注(0)|答案(2)|浏览(245)

我从Windows命令行启动SASS watch,然后使用FireFox开发者工具栏(带显示源代码)查看.scss文件。
一切正常,但我意识到我的最终.css输出文件添加了一个额外的最后一行,如:

/*# sourceMappingURL=index.css.map */

因为在我的公司,我不允许离开这个评论,我想知道如果我必须手动删除它每次或有任何方法来自动删除它时,我停止SASS手表。
除了手动删除该行之外,问题是我使用Git进行版本控制,因此只要启动SASS(--sass watch...)就会使.css文件在添加额外行时显示为Modified by GIT(因此它会显示在要提交的文件中)

dy1byipe

dy1byipe1#

您现在看到的是sourcemap,它将已编译CSS中的CSS类Map到各个SASS文件。从SASS 3.4开始,sourcemap默认启用。要禁用它们,请使用--sourcemap=none,该行将不再添加,也不会生成sourcemap。
您的命令将类似于以下内容:

sass --watch --sourcemap=none path/to/sass:path/to/css
fkaflof6

fkaflof62#

current Sass中:

sass --no-source-map ...

用法

$ sass --version && sass --help
1.44.0
Compile Sass to CSS.

Usage: sass <input.scss> [output.css]
       sass <input.scss>:<output.css> <input/>:<output/> <dir/>

=== Input and Output ===================
    --[no-]stdin               Read the stylesheet from stdin.
    --[no-]indented            Use the indented syntax for input from stdin.
-I, --load-path=<PATH>         A path to use when resolving imports.
                               May be passed multiple times.
-s, --style=<NAME>             Output style.
                               [expanded (default), compressed]
    --[no-]charset             Emit a @charset or BOM for CSS with non-ASCII characters.
                               (defaults to on)
    --[no-]error-css           When an error occurs, emit a stylesheet describing it.
                               Defaults to true when compiling to a file.
    --update                   Only compile out-of-date stylesheets.

=== Source Maps ========================
    --[no-]source-map          Whether to generate source maps.
                               (defaults to on)
    --source-map-urls          How to link from source maps to source files.
                               [relative (default), absolute]
    --[no-]embed-sources       Embed source file contents in source maps.
    --[no-]embed-source-map    Embed source map contents in CSS.

=== Other ==============================
-w, --watch                    Watch stylesheets and recompile when they change.
    --[no-]poll                Manually check for changes rather than using a native watcher.
                               Only valid with --watch.
    --[no-]stop-on-error       Don't compile more files once an error is encountered.
-i, --interactive              Run an interactive SassScript shell.
-c, --[no-]color               Whether to use terminal colors for messages.
    --[no-]unicode             Whether to use Unicode characters for messages.
-q, --[no-]quiet               Don't print warnings.
    --[no-]quiet-deps          Don't print compiler warnings from dependencies.
                               Stylesheets imported through load paths count as dependencies.
    --[no-]verbose             Print all deprecation warnings even when they're repetitive.
    --[no-]trace               Print full Dart stack traces for exceptions.
-h, --help                     Print this usage information.
    --version                  Print the version of Dart Sass.

(例如,在sass-maven-plugin(及其forks)中):

-DomitSourceMapingUrl=true

相关问题