aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.28k stars 45 forks source link

add support for storybook vite #33

Closed ilovejs closed 2 years ago

ilovejs commented 3 years ago

https://github.com/eirslett/storybook-builder-vite

After init, .storybook/main.js

This won't work

const tsconfigPaths = require("vite-tsconfig-paths")

module.exports = {
    stories: [
        "../src/components/**/*.stories.@(ts|tsx)",
    ],
    addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
    core: {
        builder: "storybook-builder-vite",
    },
    async viteFinal(config, { configType }) {
        // customize the Vite config here
        config.resolve.alias.foo = "bar"
        // config.resolve.modules.push(path.resolve(__dirname, "../src"))

        config.plugins = [tsconfigPaths()]

        return config
    },
}
jagadish-k commented 3 years ago

@ilovejs , this works for me ..

const tsconfigPaths = require('vite-tsconfig-paths').default;
orbiteleven commented 2 years ago

FWIW, I needed to do this to get things working with storybook-builder-vite:

...
async viteFinal(config) {
    config.plugins = [...config.plugins, tsconfigPaths()];

    return config;
}
...
Radinax commented 2 years ago

FWIW, I needed to do this to get things working with storybook-builder-vite:

...
async viteFinal(config) {
  config.plugins = [...config.plugins, tsconfigPaths()];

  return config;
}
...

Fixed my problem! It was failing to use the imports I was using in my code