Skip to content

Commit

Permalink
fix(module): move aliases to preset (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz authored Nov 30, 2020
1 parent bd0854d commit 33beee1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ async function getStorybookConfig (options: StorybookOptions) {
...options,
staticDir,
frameworkPresets: [
...vueOptions.frameworkPresets,
require.resolve('./preset')
require.resolve('./preset'),
...vueOptions.frameworkPresets
]
}
}
Expand Down
17 changes: 16 additions & 1 deletion src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
import path from 'path'
import * as webpack from 'webpack'
import { WebpackExtras } from './types'

export default {
addons: []
webpackFinal (config: webpack.Configuration, extras: WebpackExtras): webpack.Configuration {
// Aliases
const buildDir = extras.nuxt.options.buildDir
config.resolve.alias = {
...extras.nuxtWebpackConfig.resolve.alias,
...config.resolve.alias,
'~storybook': path.resolve(__dirname, '../storybook'),
// Nuxt plugins alias
...extras.nuxtBuilder.plugins.reduce((map, plugin) => ({ ...map, [plugin.name]: path.resolve(buildDir, plugin.src) }), {})
}
return config
}
}
11 changes: 0 additions & 11 deletions src/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'path'
import * as webpack from 'webpack'
import { WebpackExtras } from './types'

Expand Down Expand Up @@ -47,16 +46,6 @@ export function getWebpackConfig (config: webpack.Configuration, extras: Webpack
...extras.nuxtWebpackConfig.module.rules
]

// Aliases
const buildDir = extras.nuxt.options.buildDir
config.resolve.alias = {
...extras.nuxtWebpackConfig.resolve.alias,
...config.resolve.alias,
'~storybook': path.resolve(__dirname, '../storybook'),
// Nuxt plugins alias
...extras.nuxtBuilder.plugins.reduce((map, plugin) => ({ ...map, [plugin.name]: path.resolve(buildDir, plugin.src) }), {})
}

// Return the altered config
return config
}

0 comments on commit 33beee1

Please sign in to comment.