生成源映射时出错 - grunt 和 sass 配置

2024-06-19

我正在尝试将 sass 与 grunt 一起使用。我已经在我的路径中安装了 ruby​​、sass 和 grunt。
版本是,

节点:0.10.20
npm:11.3.1
grunt-cli:0.1.13
咕噜声:0.4.5
萨斯:3.4.4

我的包 json 是,

"private": true,
"devDependencies": {
    "express": "4.x",
    "grunt": "~0.4.1",
    "grunt-contrib-sass": "~0.3.0",
    "grunt-contrib-watch": "~0.4.4" 
}

我的咕噜声文件是,

module.exports = function(grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        sass: {
            dist: {
                files: {
                    'style/style.css' : 'sass/home.scss'
                }
            }
        },
        watch: {
            css: {
                files: '**/*.scss',
                tasks: ['sass']
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.registerTask('default',['watch']);
}

现在,如果我尝试“grunt”命令,我会收到以下错误。有什么帮助吗?

运行:grunt 或 grunt watch 或 grunt sass

error:

Running "sass:dist" (sass) task
Error: Error generating source map: couldn't determine public URL for the source
 stylesheet.
         No filename is available so there's nothing for the source map to link
to.
        on line  of standard input
  Use --trace for backtrace.
Warning: Error: Error generating source map: couldn't determine public URL for t
he source stylesheet.
         No filename is available so there's nothing for the source map to link
to.
        on line  of standard input
  Use --trace for backtrace. Use --force to continue.

Aborted due to warnings.

任何想法?


您似乎没有安装指南针。你可以运行gem install compass。在您最初的示例中,您将 grunt 文件设置为使用 compass,这将使您能够访问 compass mixin 和功能。

您的代码现在看起来不错并且应该可以工作,但似乎找不到您的文件。当我在电脑旁边时,我也会尝试一下。

在此期间您可以尝试sourcemap: nonesass 任务上的选项。

Update:

对我来说效果很好。你能跑吗tree -I node_modules并发布输出(除非您认为有任何敏感信息)只是为了仔细检查文件是否位于正确的位置?

我希望它看起来像这样

.
├── Gruntfile.js
├── package.json
├── sass
│   └── style.scss
└── style
    ├── style.css
    └── style.css.map

第二次更新: 你的包看起来比我新设置中的包要旧得多。尝试从头开始或执行以下操作:

安装 npm 检查更新

npm install npm-check-updates 

然后运行以下命令

  • npm-check-updates会告诉你哪些软件包已经过时
  • npm-check-updates -u将更新您的这些软件包package.json
  • npm update更新所有过时的软件包。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

生成源映射时出错 - grunt 和 sass 配置 的相关文章

随机推荐