Skip to content

Commit

Permalink
feat: add postcss-config package
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Sep 5, 2019
1 parent e05f05e commit 37179b8
Show file tree
Hide file tree
Showing 7 changed files with 1,171 additions and 32 deletions.
1 change: 1 addition & 0 deletions .postcssrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@1stg/postcss-config')
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ before_install:
install:
- yarn --frozen-lockfile
- yarn lerna bootstrap
- yarn global add postcss-cli

script:
- yarn run check
- yarn browserslist
- yarn cross-env NODE_ENV=production postcss test/test.css --verbose
- yarn build
- yarn lint
- yarn test
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"check:stylelint": "stylelint-config-prettier-check",
"check:tslint": "tslint-config-prettier-check ./tslint.json",
"check": "run-p check:*",
"lint:es": "eslint . --ext js,jsx,md,mdx,ts,tsx,vue",
"lint:es": "cross-env EFF_NO_LINK_RULES=true eslint . --ext js,jsx,md,mdx,ts,tsx,vue -f friendly",
"lint:ts": "tslint -p . -t stylish",
"lint:style:css": "stylelint --config @1stg/stylelint-config test/*.{css,less}",
"lint:style:scss": "stylelint --config @1stg/stylelint-config/scss test/*.{scss,vue}",
Expand All @@ -31,13 +31,17 @@
"@types/node": "^12.7.4",
"@types/react": "^16.9.2",
"browserslist": "^4.7.0",
"cross-env": "^5.2.1",
"eslint": "^6.3.0",
"eslint-formatter-friendly": "^7.0.0",
"husky": "^3.0.5",
"jest": "^24.9.0",
"lerna": "^3.16.4",
"lerna-changelog": "^0.8.2",
"lint-staged": "^9.2.5",
"npm-run-all": "^4.1.5",
"postcss": "^7.0.17",
"postcss-cli": "^6.1.3",
"prettier": "^1.18.2",
"react": "^16.9.0",
"rollup": "^1.20.3",
Expand All @@ -49,7 +53,8 @@
"vue": "^2.6.10"
},
"browserslist": [
"extends @1stg/browserslist-config/modern"
"extends @1stg/browserslist-config",
"> 0%"
],
"commitlint": {
"extends": [
Expand Down
27 changes: 27 additions & 0 deletions packages/postcss-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = ctx => {
const config = {
plugins: [
require('postcss-preset-env'),
require('postcss-import'),
require('postcss-normalize'),
require('autoprefixer'),
],
}

if (ctx.env === 'production') {
config.plugins.push(
require('cssnano', {
preset: [
'default',
{
discardComments: {
removeAll: true,
},
},
],
}),
)
}

return config
}
21 changes: 21 additions & 0 deletions packages/postcss-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@1stg/postcss-config",
"version": "0.0.0",
"description": "Personal but Shareable PostCSS Configuration for all 1stG.me projects.",
"repository": "[email protected]:1stG/configs.git",
"author": "JounQin <[email protected]>",
"license": "MIT",
"peerDependencies": {
"postcss": "^7.0.17"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"autoprefixer": "^9.6.1",
"cssnano": "^4.1.10",
"postcss-import": "^12.0.1",
"postcss-normalize": "^8.0.1",
"postcss-preset-env": "^6.7.0"
}
}
4 changes: 4 additions & 0 deletions test/test.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* {
box-sizing: border-box;
}

a {
color: red;
}
Loading

0 comments on commit 37179b8

Please sign in to comment.