Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
7be3b101
Unverified
Commit
7be3b101
authored
May 16, 2020
by
JJ Kasper
Committed by
GitHub
May 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add experimental Storybook preset (#12934)
parent
9d17d9ed
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
package.json
packages/next-plugin-storybook/package.json
+11
-0
preset.js
packages/next-plugin-storybook/preset.js
+62
-0
readme.md
packages/next-plugin-storybook/readme.md
+3
-0
No files found.
packages/next-plugin-storybook/package.json
0 → 100644
View file @
7be3b101
{
"name"
:
"@next/plugin-storybook"
,
"version"
:
"9.4.1-canary.7"
,
"repository"
:
{
"url"
:
"zeit/next.js"
,
"directory"
:
"packages/next-plugin-storybook"
},
"peerDependencies"
:
{
"next"
:
"*"
}
}
packages/next-plugin-storybook/preset.js
0 → 100644
View file @
7be3b101
const
{
PHASE_PRODUCTION_BUILD
}
=
require
(
'next/constants'
)
const
{
findPagesDir
}
=
require
(
'next/dist/lib/find-pages-dir'
)
const
loadConfig
=
require
(
'next/dist/next-server/server/config'
).
default
const
getWebpackConfig
=
require
(
'next/dist/build/webpack-config'
).
default
const
CWD
=
process
.
cwd
()
async
function
webpackFinal
(
config
)
{
const
pagesDir
=
findPagesDir
(
CWD
)
const
nextConfig
=
await
loadConfig
(
PHASE_PRODUCTION_BUILD
,
CWD
)
const
nextWebpackConfig
=
await
getWebpackConfig
(
CWD
,
{
pagesDir
,
entrypoints
:
{},
isServer
:
false
,
target
:
'server'
,
config
:
nextConfig
,
buildId
:
'storybook'
,
})
config
.
plugins
=
[...
config
.
plugins
,
...
nextWebpackConfig
.
plugins
]
config
.
resolve
=
{
...
config
.
resolve
,
...
nextWebpackConfig
.
resolve
,
}
config
.
module
.
rules
=
[
...
config
.
module
.
rules
.
filter
(
rule
=>
{
// the rules we're filtering use RegExp for the test
if
(
!
rule
.
test
instanceof
RegExp
)
return
true
// use Next.js' built-in CSS
if
(
rule
.
test
.
test
(
'hello.css'
))
{
return
false
}
// use next-babel-loader instead of storybook's babel-loader
if
(
rule
.
test
.
test
(
'hello.js'
)
&&
Array
.
isArray
(
rule
.
use
)
&&
rule
.
use
[
0
].
loader
===
'babel-loader'
)
{
return
false
}
return
true
}),
...
nextWebpackConfig
.
module
.
rules
.
map
(
rule
=>
{
// we need to resolve next-babel-loader since it's not available
// relative with storybook's config
if
(
rule
.
use
&&
rule
.
use
.
loader
===
'next-babel-loader'
)
{
rule
.
use
.
loader
=
require
.
resolve
(
'next/dist/build/webpack/loaders/next-babel-loader'
)
}
return
rule
}),
]
return
config
}
module
.
exports
=
{
webpackFinal
,
}
packages/next-plugin-storybook/readme.md
0 → 100644
View file @
7be3b101
# Unstable @next/plugin-storybook
This package is still very experimental and should not be used at this point
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment