gpt4 book ai didi

javascript - gulp sourcemap 已创建但无法正常工作

转载 作者:行者123 更新时间:2023-11-30 09:53:25 26 4
gpt4 key购买 nike

样式

无样式

@import "one.less";
@import "two.less";

少一个

body { background:red; }

少了两个

body { font-size: 12px; }

Gulpfile.js

var gulp = require('gulp');
var less = require('gulp-less');
var sourcemaps = require('gulp-sourcemaps');

gulp.src('./src/assets/less/styles.less')
.pipe(less())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/css/'));

结果:创建了 styles.css + styles.map.css,但是当我进入网页时 map 文件没有加载(而且当我检查“body”时我看到了样式。 CSS)

链接
少喝 - https://github.com/plus3network/gulp-less
gulp-sourcemaps - https://github.com/floridoo/gulp-sourcemaps

我很沮丧,我很感激任何帮助。谢谢。

最佳答案

在初始化 sourcemap 插件之前,您要“管道”到 less(),正确的方法是:

var gulp = require('gulp');
var less = require('gulp-less');
var sourcemaps = require('gulp-sourcemaps');

gulp.src('./src/assets/less/styles.less')
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(less())//<<< between init and write
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/css/'));

关于javascript - gulp sourcemap 已创建但无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35231221/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com