forked from carbon-design-system/carbon-website-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Storybook): make Storybook work in this repo
* Ensures Babel7 is used for Storybook * Ensures Gatsby code included in story code is transpiled * Ensure markup/markdown as well as raw CSS files go through appropriate WebPack loaders * Workaround for Storybook build failure with loading images on GH * Other misc fixes Refs carbon-design-system#313.
- Loading branch information
Showing
10 changed files
with
87 additions
and
39 deletions.
There are no files selected for viewing
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,16 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"browsers": ["last 1 versions", "Firefox ESR"] | ||
} | ||
} | ||
], | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,65 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
{ loader: 'style-loader' }, | ||
{ | ||
loader: 'css-loader', | ||
options: { importLoaders: 2 }, | ||
}, | ||
{ | ||
loader: 'postcss-loader', | ||
options: { | ||
plugins: () => [ | ||
require('autoprefixer')({ | ||
browsers: ['last 1 version', 'ie >= 11'], | ||
}), | ||
], | ||
module.exports = storybookBaseConfig => { | ||
const babelLoaderRule = storybookBaseConfig.module.rules.find(rule => /\/babel-loader\//i.test(rule.loader)); | ||
return ({ | ||
...storybookBaseConfig, | ||
module: { | ||
...storybookBaseConfig.module, | ||
rules: [ | ||
...storybookBaseConfig.module.rules.filter(rule => rule !== babelLoaderRule), | ||
{ | ||
...babelLoaderRule, | ||
exclude: /(node_modules)[\/\\](?!(gatsby)[\/\\]).*/, | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
{ loader: 'style-loader' }, | ||
{ | ||
loader: 'css-loader', | ||
options: { importLoaders: 2 }, | ||
}, | ||
}, | ||
{ | ||
loader: 'sass-loader', | ||
options: { | ||
includePaths: [path.resolve(__dirname, '..', 'node_modules')], | ||
], | ||
}, | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
{ loader: 'style-loader' }, | ||
{ | ||
loader: 'css-loader', | ||
options: { importLoaders: 2 }, | ||
}, | ||
{ | ||
loader: 'postcss-loader', | ||
options: { | ||
plugins: () => [ | ||
require('autoprefixer')({ | ||
browsers: ['last 1 version', 'ie >= 11'], | ||
}), | ||
], | ||
}, | ||
}, | ||
{ | ||
loader: 'sass-loader', | ||
options: { | ||
includePaths: [path.resolve(__dirname, '..', 'node_modules')], | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
test: /\.md$/, | ||
loaders: ['html-loader', 'markdown-loader'], | ||
}, | ||
{ | ||
test: /\.(html|svg)$/, | ||
loader: 'html-loader', | ||
options: { | ||
minimize: false, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
} | ||
}); | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1937,12 +1937,12 @@ [email protected], babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: | |
esutils "^2.0.2" | ||
js-tokens "^3.0.2" | ||
|
||
[email protected]: | ||
[email protected], babel-core@^7.0.0-bridge.0: | ||
version "7.0.0-bridge.0" | ||
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece" | ||
integrity sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg== | ||
|
||
babel-core@^6.0.0, babel-core@^6.26.0, babel-core@^6.26.3: | ||
babel-core@^6.0.0, babel-core@^6.26.0: | ||
version "6.26.3" | ||
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207" | ||
integrity sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA== | ||
|