Skip to content

Commit

Permalink
docs: Configure styleguidist 📚
Browse files Browse the repository at this point in the history
For now only cozy-harvest-lib is concerned but
setting styleguidist up on monorepo root will
allow us to easily generate doc for other
packages in the future.
  • Loading branch information
gregorylegarec committed Mar 14, 2019
1 parent 54849d7 commit b9659dd
Show file tree
Hide file tree
Showing 6 changed files with 3,306 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
*.log
dist
coverage
docs/build
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['cozy-app']
}
43 changes: 43 additions & 0 deletions docs/styleguidist.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const webpack = require('webpack')

const lib = process.env.TARGET
const styleguideDir = `./build${lib ? `/${lib}` : ''}`

module.exports = {
components: `../packages/${lib || '**'}/src/components/**/*.jsx`,
serverPort: 6262,
styleguideDir,
webpackConfig: {
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules\/(?!(cozy-ui)\/).*/,
loader: 'babel-loader'
},
{
test: /node_modules\/cozy-ui\/(.*)\.styl$/,
loader: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]--[hash:base64:5]'
}
}
]
}
]
},
plugins: [
new MiniCssExtractPlugin('[name].css'),
new webpack.DefinePlugin({
'process.env': {
USE_REACT: 'true'
}
})
]
}
}
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@
"url": "https://github.com/cozy/cozy-libs/issues"
},
"scripts": {
"build:doc:react": "styleguidist build --config docs/styleguidist.config.js",
"deploy:doc": "git-directory-deploy --directory docs/build/ --branch gh-pages",
"lint": "eslint . --ext js,jsx",
"test": "lerna run --parallel test",
"build": "lerna run --parallel build"
"build": "lerna run --parallel build",
"watch:doc:react": "styleguidist server --config docs/styleguidist.config.js"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"babel-loader": "^8.0.5",
"babel-preset-cozy-app": "^1.5.0",
"css-loader": "^2.1.1",
"git-directory-deploy": "^1.5.1",
"husky": "1.3.1",
"lerna": "2.11.0"
"lerna": "2.11.0",
"mini-css-extract-plugin": "^0.5.0",
"react-styleguidist": "^9.0.4",
"webpack": "^4.29.6"
},
"husky": {
"hooks": {
Expand Down
5 changes: 4 additions & 1 deletion packages/cozy-harvest-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
},
"scripts": {
"build": "babel src -d dist --copy-files",
"build:doc:react": "(cd ../.. && TARGET=cozy-harvest-lib yarn build:doc:react)",
"deploy:doc": "(cd ../.. && yarn deploy:doc)",
"prebuild": "yarn tx",
"prepublishOnly": "yarn build",
"test": "jest --verbose --coverage",
"tx": "tx pull --all",
"watch": "babel src -d dist --copy-files --watch"
"watch": "babel src -d dist --copy-files --watch",
"watch:doc:react": "(cd ../.. && TARGET=cozy-harvest-lib yarn watch:doc:react)"
},
"dependencies": {
"cozy-client": "6.9.0",
Expand Down
Loading

0 comments on commit b9659dd

Please sign in to comment.