简体   繁体   English

相对于文件系统(而不是网站)的SourceMap文件位置更少

[英]Less SourceMap file location relative to filesystem, not website

I have a file structure that looks like this (simplified for brevity): 我有一个看起来像这样的文件结构(为简便起见简化):

/less/
     /styles.less
/public/
       /css/
           /styles.css
           /styles.css.map
       /images/
       index.php
/gruntfile.js

Gruntfile.js: Gruntfile.js:

less: {
    options: {
        sourceMap: true,
        sourceMapFilename: 'public/css/styles.css.map',
        sourceMapURL: '/css/styles.css.map',
        sourceMapRootpath: '/'
    }
    files: {
        'public/css/styles.css': 'less/styles.less'
    }
}

In the index file: <link rel="stylesheet" href="/css/styles.css"> 在索引文件中: <link rel="stylesheet" href="/css/styles.css">

Now in dev tools, it's looking for styles.less in http://localhost:3845/less/styles.less , which doesn't exist, since only /public/ is exposed to the website. 现在,在开发工具,它在寻找styles.lesshttp://localhost:3845/less/styles.less ,它不存在,因为只有/public/暴露的网站。

It used to map the files to my local machine correctly, without any additional steps, but doesn't anymore. 它曾经用于将文件正确地映射到我的本地计算机,而无需任何其他步骤,但是现在不再。 I'm not sure what happened or how to set it up so it does. 我不确定发生了什么或如何设置它。

I'm using the latest grunt-contrib-less (1.0.0). 我正在使用最新的grunt-contrib-less(1.0.0)。

The browser can not read the less folder, so remove your Less files to your public folder (or give the web server access to the less folder ) 浏览器无法读取less文件夹,因此请将您的Less文件删除到公用文件夹中(或让Web服务器访问less文件夹)

Alternatively set Less's source-map-less-inline and source-map-map-inline options: 或者设置Less的source-map-less-inlinesource-map-map-inline选项:

options: {
sourceMap: true,
sourceMapFileInline: true,
outputSourceFiles: true
}

The above puts the map, with the content of your Less files, into the CSS files. 上面的代码将包含您的Less文件内容的地图放入CSS文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM