Skip to content

Commit

Permalink
Storybook: Improves logging of build/examples/patching during build
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Feb 12, 2020
1 parent 43a6968 commit 33c9fda
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
17 changes: 11 additions & 6 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')

const entryPropertyName = {
cjs: 'main',
Expand Down Expand Up @@ -27,12 +28,10 @@ module.exports = async ({ config }) => {
: 'styled-components'

console.log(
`
Building Storybook with the ${MODULE_TYPE.toUpperCase()} build of "${PACKAGE}"
Imports of "atomic-layout" aliased to "${moduleFilePath}"
Storybook stories loaded from "${examplesDir}"
`,
`Build: ${chalk.cyan(PACKAGE)} (${chalk.gray(MODULE_TYPE.toUpperCase())})`,
)
console.log(`Module: ${chalk.magenta(moduleFilePath)}`)
console.log(`Examples: ${chalk.magenta(examplesDir)}`)

if (!fs.existsSync(moduleFilePath)) {
throw new Error(
Expand All @@ -44,6 +43,7 @@ Please make sure you point to the existing build module.
}

/**
* @see https://github.com/storybookjs/storybook/issues/3346
* @todo Replace this workaround with something native to Storybook
* or find a better solution how to compile external "examples" directory.
*
Expand All @@ -58,8 +58,13 @@ Please make sure you point to the existing build module.
*/
const patchBabelLoader = (rule) => {
if (rule.include) {
console.log('babel-loader successfully patched!')
rule.include = rule.include.concat(examplesDir)

console.log(
chalk.green(
`Patched babel-loader successfully to include "${examplesDir}"`,
),
)
}
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@storybook/addon-actions": "5.3.7",
"@storybook/addon-links": "5.3.7",
"@storybook/react": "5.3.7",
"chalk": "3.0.0",
"cross-env": "5.2.0",
"husky": "3.1.0",
"jest": "24.9.0",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4775,6 +4775,14 @@ [email protected], chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.4.
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"

[email protected], chalk@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
Expand All @@ -4786,14 +4794,6 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"

chalk@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4"
integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

character-entities-legacy@^1.0.0:
version "1.1.3"
resolved "https://registry.yarnpkg.com/character-entities-legacy/-/character-entities-legacy-1.1.3.tgz#3c729991d9293da0ede6dddcaf1f2ce1009ee8b4"
Expand Down

0 comments on commit 33c9fda

Please sign in to comment.