Skip to content

Commit

Permalink
Merge pull request #18 from perimetre/fix/Bug-with-purgecss-cleaning-…
Browse files Browse the repository at this point in the history
…classes_CU-3k7em3

1.4.2
  • Loading branch information
yanikproulx authored Mar 8, 2021
2 parents a42f8aa + a9c385f commit 11c210c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

## [1.4.2] - 2021-03-08

### Fixed

- Fixed an issue where purgecss was purging more than it needed to
- Fixed a bug where the WYSIWYGInput text align buttons were not toggling correctly when switching from an alignment to another

## [1.4.1] - 2021-03-04

### Fixed
Expand Down
35 changes: 28 additions & 7 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ You will need:
1. Edit the `tailwind.config.js` file, adding the following `preset`:
```diff
module.exports = {
purge: [
'./pages/**/*.{js,ts,jsx,tsx,css}',
'./components/**/*.{js,ts,jsx,tsx,css}',
+ './node_modules/@perimetre/ui/**/*.{js,ts,jsx,tsx,css}',
+ '!./node_modules/@perimetre/ui/**/storybookMappers.tsx'
],
+ purge: false, // Turning tailwindcss purge off because we're customizing the execution order in postcss.config.js
darkMode: false, // or 'media' or 'class'
theme: {
extend: {}
Expand All @@ -56,7 +51,33 @@ You will need:
+ presets: [require('@perimetre/ui').defaultPreset]
};
```
2. [Check out the preset to learn more about the values](../src/presets/default-preset.js)
1. Edit the `postcss.config.js` file, adding the following `preset`:
```diff
module.exports = {
plugins: {
+ 'postcss-import': {}, // Import must come before tailwind
tailwindcss: {},
+ // Other plugins come after tailwind and before postcss-purgecss + autoprefixer
+ 'postcss-nested': {},
+ 'postcss-combine-media-query': {}, // Media query must come before duplicated-selectors
+ 'postcss-combine-duplicated-selectors': {},
+ // postcss-purgecss should always be last before autoprefixer
+ '@fullhuman/postcss-purgecss': {
+ content: [
+ // All project components
+ './pages/**/*.{js,ts,jsx,tsx,css}',
+ './components/**/*.{js,ts,jsx,tsx,css}',
+ // Consider the components in the ui
+ './node_modules/@perimetre/ui/**/*.{js,ts,jsx,tsx,css}',
+ '!./node_modules/@perimetre/ui/**/storybookMappers.tsx' // ignore the storybookMappers.tsx inside @perimetre/ui because that should only be used by the ui package itself
+ ]
+ },
+ // autoprefixer should always be the last one
autoprefixer: {}
}
};
```
1. [Check out the preset to learn more about the values](../src/presets/default-preset.js)

### Importing the font

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@perimetre/ui",
"description": "A component library made by @perimetre",
"version": "1.4.1",
"version": "1.4.2",
"repository": {
"type": "git",
"url": "git+https://github.com/perimetre/ui.git"
Expand Down Expand Up @@ -37,7 +37,7 @@
"check-commit": "npm run type-check && npm run prettier && npm run lint:css && npm run lint:fix && npm run rollup:build",
"storybook": "start-storybook -s ./public -p 6006",
"build-storybook": "build-storybook -s ./public",
"serve-storybook": "npm run build-storybook && http-server ./storybook-static",
"serve-storybook": "npm run build-storybook && http-server ./storybook-static -c-1",
"rollup:build": "rollup -c",
"rollup:watch": "rollup -c -w",
"prepare": "npm run rollup:build"
Expand Down
3 changes: 3 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ module.exports = {
'postcss-nested': {},
'postcss-combine-media-query': {}, // Media query must come before duplicated-selectors
'postcss-combine-duplicated-selectors': {},
'@fullhuman/postcss-purgecss': {
content: ['./src/**/*.{js,ts,jsx,tsx,css}', './.storybook/**/*.{js,ts,jsx,tsx,css}']
},
autoprefixer: {}
}
};
5 changes: 3 additions & 2 deletions src/utils/wysiwyg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ export const toggleBlockData = async (
// For each entry in the provided data object
Object.entries(data || {}).forEach(([key, value]) => {
// If the current data DOES NOT have the key
if (!currentData.has(key)) {
// Add the key to the new data, because we should keep ip
// Of if there is but the value is a different one, we then want to update the value
if (!currentData.has(key) || currentData.get(key) !== value) {
// Add the key to the new data, because we should keep it
newData[key] = value;
}

Expand Down
3 changes: 2 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Ref: https://tailwindcss.com/docs/configuration

module.exports = {
purge: ['./src/**/*.{js,ts,jsx,tsx,css}', './.storybook/**/*.{js,ts,jsx,tsx,css}'],
purge: false,
darkMode: false, // or 'media' or 'class'
presets: [require('./src/presets/default-preset')]
};

0 comments on commit 11c210c

Please sign in to comment.