Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sugarss support #1941

Merged
merged 8 commits into from Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -103,6 +103,7 @@
"sinon": "^5.0.1",
"sourcemap-validator": "^1.0.6",
"stylus": "^0.54.5",
"sugarss": "^2.0.0",
"typescript": "^3.0.0",
"vue": "^2.5.16",
"vue-template-compiler": "^2.5.16"
Expand Down
1 change: 1 addition & 0 deletions src/Parser.js
Expand Up @@ -29,6 +29,7 @@ class Parser {
this.registerExtension('css', './assets/CSSAsset');
this.registerExtension('pcss', './assets/CSSAsset');
this.registerExtension('postcss', './assets/CSSAsset');
this.registerExtension('sss', './assets/SSSAsset');
this.registerExtension('styl', './assets/StylusAsset');
this.registerExtension('stylus', './assets/StylusAsset');
this.registerExtension('less', './assets/LESSAsset');
Expand Down
31 changes: 31 additions & 0 deletions src/assets/SSSAsset.js
@@ -0,0 +1,31 @@
const postcss = require('postcss');
const localRequire = require('../utils/localRequire');
const Asset = require('../Asset');

class SSSAsset extends Asset {
constructor(name, options) {
super(name, options);
this.type = 'css';
}

async generate() {
let sugarss = await localRequire('sugarss', this.name);

await this.loadIfNeeded();

let {css} = await postcss().process(this.contents, {
from: this.name,
to: this.name,
parser: sugarss
});

return [
{
type: 'css',
value: css
}
];
}
}

module.exports = SSSAsset;
5 changes: 5 additions & 0 deletions test/integration/sugarss/index.sss
@@ -0,0 +1,5 @@
input.spoiler-input
display: none

.spoiler_link
cursor: pointer
21 changes: 21 additions & 0 deletions test/sugarss.js
@@ -0,0 +1,21 @@
const assert = require('assert');
const {bundle, assertBundleTree} = require('./utils');
const fs = require('../src/utils/fs');
const path = require('path');

describe('sugarss', function() {
it('should correctly parse SugarSS asset', async function() {
let b = await bundle(__dirname + '/integration/sugarss/index.sss');

await assertBundleTree(b, {
name: 'index.css',
assets: ['index.sss']
});

let cssContent = await fs.readFile(
path.join(__dirname, '/dist/index.css'),
'utf8'
);
assert(cssContent.includes('{'));
});
});
14 changes: 14 additions & 0 deletions yarn.lock
Expand Up @@ -5566,6 +5566,14 @@ postcss@^6.0.1, postcss@^6.0.19, postcss@^6.0.20:
source-map "^0.6.1"
supports-color "^5.4.0"

postcss@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.2.tgz#7b5a109de356804e27f95a960bef0e4d5bc9bb18"
dependencies:
chalk "^2.4.1"
source-map "^0.6.1"
supports-color "^5.4.0"

posthtml-extend@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/posthtml-extend/-/posthtml-extend-0.2.1.tgz#d023ce7ce4dd6071071b50e315dfefa87da8a979"
Expand Down Expand Up @@ -6655,6 +6663,12 @@ stylus@0.54.5, stylus@^0.54.5:
sax "0.5.x"
source-map "0.1.x"

sugarss@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/sugarss/-/sugarss-2.0.0.tgz#ddd76e0124b297d40bf3cca31c8b22ecb43bc61d"
dependencies:
postcss "^7.0.2"

supports-color@4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.4.0.tgz#883f7ddabc165142b2a61427f3352ded195d1a3e"
Expand Down