Skip to content

feat!: support redirect.style.path and redirect.style.extension #618

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

Merged
merged 4 commits into from
Jan 3, 2025

Conversation

SoonIter
Copy link
Member

@SoonIter SoonIter commented Dec 26, 2024

Summary

feat(css-external): use redirect.style.path import '@/css/button.css'

redirect.style

redirect.style.path

Whether to automatically redirect the import path when importing style files, the rules are the same as redirect.js.path.

  • Type: boolean

  • Default: true

  • Example:

When importing normal style files:

import '@/foo.css'; // source code of './src/bar.ts' ↓
import './foo.css'; // expected output of './dist/bar.js'

import '@/foo.css'; // source code of './src/utils/index.ts' ↓
import '../foo.css'; // expected output of './dist/utils/index.js'

When importing CSS Modules files:

import styles from '@/foo.css'; // source code of './src/bar.ts' ↓
import styles from './foo.css'; // expected output of './dist/bar.js'

import styles from '@/foo.css'; // source code of './src/utils/index.ts' ↓
import styles from '../foo.css'; // expected output of './dist/utils/index.js'

redirect.style.extension

Whether to redirect style file extensions.

  • Type: boolean
  • Default: true

When set to true, When importing a normal style file, the path will be rewritten to the .css file. When importing CSS Modules, the path will be rewritten to the corresponding JavaScript output file.

When set to false, The file extension will remain unchanged from the original import path.

  • Example:

When importing from a .less file:

import './index.less'; // source code ↓
import './index.css'; // expected output

import styles from './index.module.less'; // source code ↓
import styles from './index.module.mjs'; // expected output

Related Links

close #621

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Dec 26, 2024

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit 0d494a2
🔍 Latest deploy log https://app.netlify.com/sites/rslib/deploys/677791a0ca061e0008b5a3f9
😎 Deploy Preview https://deploy-preview-618--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Timeless0911
Copy link
Contributor

I think we should use redirect.style config.

@SoonIter SoonIter changed the title fix(css-external): use alias import '@/css/button.css' feat(css-external): use redirect.style.path import '@/css/button.css' Dec 27, 2024
@SoonIter SoonIter changed the title feat(css-external): use redirect.style.path import '@/css/button.css' feat(css-external): add redirect.style.path to handle import '@/css/button.css' Dec 27, 2024
@SoonIter SoonIter changed the title feat(css-external): add redirect.style.path to handle import '@/css/button.css' feat(css-external): add redirect.style.path to handle import '@/css/button.css' Dec 27, 2024
@SoonIter SoonIter changed the title feat(css-external): add redirect.style.path to handle import '@/css/button.css' feat(css-external)!: add redirect.style.path to handle import '@/css/button.css' Dec 27, 2024
@SoonIter SoonIter marked this pull request as ready for review December 27, 2024 07:25
@SoonIter SoonIter force-pushed the redirect-css branch 2 times, most recently from 08a2c31 to 471213d Compare December 27, 2024 09:57
@Timeless0911 Timeless0911 changed the title feat(css-external)!: add redirect.style.path to handle import '@/css/button.css' feat(css-external)!: support redirect.style.path and redirect.style.extension Dec 30, 2024
@SoonIter SoonIter force-pushed the redirect-css branch 2 times, most recently from 09bac79 to b57338b Compare January 2, 2025 11:29
@SoonIter SoonIter requested a review from Timeless0911 January 3, 2025 04:01
@Timeless0911 Timeless0911 changed the title feat(css-external)!: support redirect.style.path and redirect.style.extension feat!: support redirect.style.path and redirect.style.extension Jan 3, 2025
@SoonIter SoonIter enabled auto-merge (squash) January 3, 2025 07:30
@SoonIter SoonIter merged commit eda2925 into main Jan 3, 2025
16 checks passed
@SoonIter SoonIter deleted the redirect-css branch January 3, 2025 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: import css with alias should be redirected
2 participants