-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(style-compiler): upgrade postcss and cssnano (#1633)
- Loading branch information
Showing
11 changed files
with
662 additions
and
455 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/@lwc/compiler/src/__tests__/fixtures/expected-minify-no-comments.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/@lwc/compiler/src/__tests__/fixtures/expected-styled-prod.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
packages/@lwc/style-compiler/src/__tests__/fixtures/min-simple/expected.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
packages/@lwc/style-compiler/src/postcss-minify-plugins.ts
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 @@ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: MIT | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT | ||
*/ | ||
import cssnanoPreset from 'cssnano-preset-default'; | ||
|
||
const CSS_NANO_PRESET_OPTIONS = { | ||
svgo: { | ||
// The svgo plugin is async and need to be excluded. | ||
exclude: true, | ||
}, | ||
}; | ||
|
||
/** | ||
* cssnano decided to make its APIs asynchronous with v4. Because the LWC compiler transform API is | ||
* synchronous we can't use cssnano directly. For now we use the css-nano-preset-default and filter | ||
* out the plugins that are async. | ||
* https://github.com/cssnano/cssnano/blob/master/packages/cssnano-preset-default/src/index.js | ||
* | ||
* We may switch back to cssnano if/when they decide to go back to a synchronous API: | ||
* https://github.com/cssnano/cssnano/issues/68 | ||
*/ | ||
export default function() { | ||
const { plugins } = cssnanoPreset(CSS_NANO_PRESET_OPTIONS); | ||
|
||
return plugins | ||
.filter(([_, options]) => !options || !options.exclude) | ||
.map(([plugin, options]) => plugin(options)); | ||
} |
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
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
Oops, something went wrong.