Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: css node_module imports #9

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/big-tips-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@storybook/marko-vite": patch
---

Fix issue where css @imports with `~` were not being resolved.
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Use node
Expand All @@ -32,13 +32,11 @@ jobs:
- name: Format Code
run: npm run format
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[ci] format"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
name: "test: node@${{ matrix.node }}"
Expand All @@ -48,7 +46,7 @@ jobs:
node: [20]
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Use node@${{ matrix.node }}
uses: actions/setup-node@v3
with:
Expand All @@ -61,14 +59,14 @@ jobs:
- name: Run tests
run: npm run ci:test
- name: Report code coverage
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
release:
runs-on: ubuntu-latest
needs: [format, test]
if: "${{ github.repository_owner == 'storybookjs' && github.event_name == 'push' }}"
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
with:
Expand Down
23 changes: 17 additions & 6 deletions packages/frameworks/marko-vite/src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { PresetProperty } from "@storybook/types";
import { mergeConfig } from "vite";
import { hasVitePlugins } from "@storybook/builder-vite";
import type { StorybookConfig } from "./types";

Expand All @@ -22,10 +23,20 @@ export const core: PresetProperty<"core", StorybookConfig> = async (
};

export const viteFinal: StorybookConfig["viteFinal"] = async (baseConfig) => {
const { plugins = [] } = baseConfig;
if (!(await hasVitePlugins(plugins, ["@marko/vite"]))) {
const { default: markoPlugin } = await import("@marko/vite");
plugins.push(markoPlugin({ linked: false }));
}
return baseConfig;
return mergeConfig(baseConfig, {
resolve: {
alias: [
{
// Fixes https://github.com/storybookjs/storybook/issues/23147
find: /^~/,
replacement: "",
},
],
},
plugins:
// Ensure @marko/vite included unless already added.
(await hasVitePlugins(baseConfig.plugins || [], ["@marko/vite"]))
? []
: [(await import("@marko/vite")).default({ linked: false })],
});
};