Soweit ich Ihre Konfiguration den folgenden sourcemap Code generieren verstehen:
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm1haW4ubGVzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQTtFQUNFLHlCQUFBIiwiZmlsZSI6Im1haW4uY3NzIiwic291cmNlc0NvbnRlbnQiOlsiQGltcG9ydCAndmFycyc7XG5cbmJvZHl7XG4gIGJhY2tncm91bmQtY29sb3I6IEBibGF1O1xufVxuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9 */
Die codierte Version:
{"version":3,"sources":["main.less"],"names":[],"mappings":"AAEA;EACE,yBAAA","file":"main.css","sourcesContent":["@import 'vars';\n\nbody{\n background-color: @blau;\n}\n"],"sourceRoot":"/source/"}
Ihre vars.less
nicht erzeugen keine Ausgabe an die CSS und so sollte nicht in der Quellkarte enthalten sein.
Sobald Ihre vars.less
erzeugt Ausgabe, zum Beispiel .selector {p:1;}
am Ende dieser Datei hinzufügen, wird die Datei auch in der Quellkarte aufgenommen werden:
{"version":3,"sources":["vars.less","main.less"],"names":[],"mappings":"AACA;EAAW,IAAA;;ACCX;EACE,yBAAA","file":"main.css","sourcesContent":["@blau : #6621ab;\n.selector {p:1;}\n","@import 'vars';\n\nbody{\n background-color: @blau;\n}\n"],"sourceRoot":"/source/"}
Beachten Sie, dass der lessc Compiler andere Option hat für Quelle Karten:
--source-map[=FILENAME] Outputs a v3 sourcemap to the filename (or output filename.map)
--source-map-rootpath=X adds this path onto the sourcemap filename and less file paths
--source-map-basepath=X Sets sourcemap base path, defaults to current working directory.
--source-map-less-inline puts the less files into the map instead of referencing them
--source-map-map-inline puts the map (and any less files) into the output css file
--source-map-url=URL the complete url and filename put in the less file
die Schluck-sourcemaps gibt das gleiche Ergebnis wie Kompilieren mit den beiden --source-map-less-inline
und --source-map-map-inline
Optionen
Hallo Bass !! Durch Ersetzen von 'gulp.src ('./ less/main.less')' durch 'gulp.src ('./ less/*. Less')' das Erzeugen der vars.css-Datei mit eigenem Quellmapping. Dann, einschließlich vars.css in meinem HTML, kann ich sehen, dass es die Quelle ist: D Dou Sie irgendwelche Technik, um vars.less Quellenmapping in main.css einzuschließen, also muss ich nur eine Datei einschließen? Vielen Dank für Ihre Zeit! – Karlas