2016-02-15 25 views
0

上午使用postcss-scss它应该允许/ /内部scss文件。gulp + postCSS + typescript ...抛出//语法

代替,让...

` 未知字

//注射器

这里是我一饮而尽任务。

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 

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

+0

您可以发布一部分SCSS,包括失败的行吗? – Calvin

+0

hey @calvin。它是双正斜杠'/ ** @import url(http://fonts.googleapis.com/css?family=Roboto+Slab:400,700|Roboto:400,700,700italic,400italic); @ font-face { font-family:'材料图标'; font-style:normal; font-weight:400; src:url(../../ bower_components/material-design-iconfont/iconfont/MaterialIcons-Regular.eot);/*对于IE6-8 */ /** *请勿删除下面的注释。 */ //喷射器 // endinjector ' – 0101adm

回答

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 
    })); 
}); 
+0

工作。谢谢。 – 0101adm

+0

@ user3033234如果它适合您,请接受正确的答案。非常感激! – Calvin