Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
yangshun committed Jul 9, 2018
1 parent 08be000 commit 85314dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"test": {
"presets": [
"env"
],
"plugins": [
"transform-class-properties",
"transform-object-rest-spread"
]
}
}
Expand Down
13 changes: 7 additions & 6 deletions lib/server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ function getLanguage(file, refDir) {
return null;
}

async function minifyCss(cssContent) {
const {css} = await cssnano.process(cssContent, {
preset: 'default',
zindex: false,
});
return css;
function minifyCss(cssContent) {
return cssnano
.process(cssContent, {
preset: 'default',
zindex: false,
})
.then(result => result.css);
}

module.exports = {
Expand Down

5 comments on commit 85314dd

@endiliey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test are failing because of
const env = require('./env.js'); resolves differently in jest (it becomes test/env instead of server/env)

One solution is to mock the relative path or code split the env require inside getLanguage function

@yangshun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that too, but seems so troublesome. Sigh this path thingy is so annoying.

@yangshun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna take a break from Docusaurus for today. Had enough of head banging for the day 😂

@endiliey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha. I think its more of because we dont use something like webpack. All the dependency path must be manually taken care by us

@yangshun
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's one of the reason. Another thing to improve on is that we should have a utility that retrieves the siteConfig file regardless of CWD. Jest, ESLint, Babel (any tool that relies on a config) all have some sort of config retrieval code. With that we can stop relying on CWD.

Please sign in to comment.