Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
fix(docz-core): typescript resolve extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jun 21, 2018
1 parent c58b676 commit 689b057
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/typescript/src/components/Alert.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ menu: Components
---

import { Playground, PropsTable } from 'docz'
import Alert from './Alert.tsx'
import Alert from './Alert'

# Alert

Expand Down
37 changes: 24 additions & 13 deletions packages/docz-core/src/bundlers/webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,30 @@ export const createConfig = (babelrc: BabelRC) => (
path.dirname(require.resolve('@babel/runtime/package.json'))
)

config.resolve.extensions
.merge([
'.web.js',
'.mjs',
'.js',
'.json',
'.web.jsx',
'.jsx',
'.mdx',
...(args.typescript ? ['.ts', '.tsx'] : []),
])
.end()
.modules.add('node_modules')
const addExtensions = (resolve: any) => {
resolve.extensions
.add('.web.js')
.add('.mjs')
.add('.js')
.add('.json')
.add('.web.jsx')
.add('.jsx')
.add('.mdx')
.end()

if (args.typescript) {
resolve.extensions
.prepend('.ts')
.prepend('.tsx')
.end()
}
}

addExtensions(config.resolve)
addExtensions(config.resolveLoader)

config.resolve.modules
.add('node_modules')
.add(srcPath)
.add(paths.root)

Expand Down

0 comments on commit 689b057

Please sign in to comment.