【问题标题】:gulp + postCSS + typescript ... throws on // syntaxgulp + postCSS + typescript ... 抛出 // 语法
【发布时间】:2016-05-26 19:12:51
【问题描述】:

我正在使用postcss-scss,它应该允许 // 在 scss 文件中。

相反,得到...

` 不认识的字

// 注射器

这是我的 gulp 任务。

var postcss     = require('gulp-postcss');
var reporter    = require('postcss-reporter');
var syntax_scss = require('postcss-scss');
var stylelint   = require('stylelint');

gulp.task("scss-lint", function() {  var stylelintConfig = {
"plugins": [
  "stylelint-statement-max-nesting-depth"
],
"rules": {
    "statement-max-nesting-depth": [3, { countAtRules: false }],
  "block-no-empty": true,
  "color-no-invalid-hex": true,
  "declaration-colon-space-after": "always",
  "declaration-colon-space-before": "never",
  "function-comma-space-after": "always",
  "function-url-quotes": "double",
  "media-feature-colon-space-after": "always",
  "media-feature-colon-space-before": "never",
  "media-feature-name-no-vendor-prefix": true,
  "max-empty-lines": 5,
  "number-leading-zero": "never",
  "number-no-trailing-zeros": true,
  "property-no-vendor-prefix": true,
  "rule-no-duplicate-properties": true,
  "declaration-block-no-single-line": true,
  "rule-trailing-semicolon": "always",
  "selector-list-comma-space-before": "never",
  "selector-list-comma-newline-after": "always",
  "selector-no-id": true,
  "string-quotes": "double",
  "value-no-vendor-prefix": true}}

var processors = [stylelint(stylelintConfig),reporter({clearMessages: true,throwError: true})];

return gulp.src(['src/**/*.scss']).pipe(postcss(processors), {syntax: syntax_scss});});

它说 postcss-scss 应该允许 // 注释语法。

这里是完整的 scss 文件...

.slide-toggle { overflow: hidden;  transition: all 1.5s;}

.angular-google-map-wrapper {
position:relative;
height: 100%;
width: 100%;
}

.angular-google-map-container {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
}

/**
*  Do not remove the comment below. It's the markers used by gulp-inject to inject
*/
// injector
// endinjector

由于文件是自动生成的,我将无法删除 //.

【问题讨论】:

  • 您能否发布 SCSS 的一部分,包括失败的行?
  • 嘿@卡尔文。它是双斜杠/** @import url(http://fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,700,700italic,400italic); @font-face { font-family: 'Material Icons'; font-style: normal; font-weight: 400; src: url(../../bower_components/material-design-iconfont/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */ /** * Do not remove the comment below. */ // injector // endinjector

标签: sass typescript gulp postcss


【解决方案1】:

您在这里遇到的问题在最后一行:

return gulp.src(['src/**/*.scss']).pipe(postcss(processors), {syntax: syntax_scss});});

您的括号未正确包装,因此您的选项未正确传递给 postcss。

应该是:

return gulp.src(['src/**/*.scss']).pipe(postcss(processors, {syntax: syntax_scss}));});

我已对答案进行了格式化以使其更具可读性。

return gulp
  .src(['./*.scss'])
  .pipe(postcss(processors, {
    syntax: syntax_scss
  }));
});

【讨论】:

  • @user3033234 如果对您有用,请务必接受正确的答案。非常感谢!
猜你喜欢
  • 2017-10-12
  • 2016-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-14
  • 2016-02-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多