-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add PostCSS's SugarSS recognition by default * Update postcss.js * Update SSSAsset.js * Update Ast.js * Update SSSAsset.js * Update SSSAsset.js * cleanup a lil * remove parse step and fix sugarss fail
- Loading branch information
1 parent
41d8759
commit 4208bc8
Showing
6 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
5
packages/core/parcel-bundler/test/integration/sugarss/index.sss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
input.spoiler-input | ||
display: none | ||
|
||
.spoiler_link | ||
cursor: pointer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('{')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters