-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4384016
commit 0dbd92d
Showing
7 changed files
with
140 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
<template> | ||
<div> | ||
Nuxt module playground! | ||
<div>RTLCSS Nuxt module playground!</div> | ||
<div style="border: 3px solid #222"> | ||
<div class="test"> | ||
i'm auto rtl | ||
</div> | ||
</div> | ||
<div | ||
dir="rtl" | ||
style="border: 3px solid #222" | ||
> | ||
<div class="test"> | ||
i'm auto rtl | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
</script> | ||
<script setup></script> | ||
<style> | ||
.test { | ||
height: 100px; | ||
width: 100px; | ||
background-color: #ccc; | ||
margin-left: 10px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export default defineNuxtConfig({ | ||
modules: ['../src/module'], | ||
myModule: {}, | ||
rtlcss: {}, | ||
devtools: { enabled: true } | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit' | ||
import { defineNuxtModule, getNuxtVersion, installModule } from "@nuxt/kit"; | ||
import type { RTLCSSModuleOptions } from "./types"; | ||
|
||
// Module options TypeScript interface definition | ||
export interface ModuleOptions {} | ||
|
||
export default defineNuxtModule<ModuleOptions>({ | ||
export default defineNuxtModule<RTLCSSModuleOptions>({ | ||
meta: { | ||
name: 'my-module', | ||
configKey: 'myModule' | ||
name: "rtlcss", | ||
configKey: "rtlcss", | ||
}, | ||
// Default configuration options of the Nuxt module | ||
defaults: {}, | ||
setup (options, nuxt) { | ||
const resolver = createResolver(import.meta.url) | ||
defaults: { mode: "override" }, | ||
async setup(options, nuxt) { | ||
// Setup postcss plugin | ||
const postcssOptions = | ||
nuxt.options.postcss /* nuxt 3 */ /* @ts-ignore */ || | ||
nuxt.options.build.postcss | ||
.postcssOptions /* older nuxt3 */ /* @ts-ignore */ || | ||
(nuxt.options.build.postcss as any); | ||
postcssOptions.plugins = postcssOptions.plugins || {}; | ||
postcssOptions.plugins["postcss-rtlcss"] = options || {}; | ||
|
||
// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack` | ||
addPlugin(resolver.resolve('./runtime/plugin')) | ||
} | ||
}) | ||
// install postcss8 module on nuxt < 2.16 | ||
if (parseFloat(getNuxtVersion()) < 2.16) { | ||
await installModule("@nuxt/postcss8"); | ||
} | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
declare enum Mode { | ||
combined = "combined", | ||
override = "override", | ||
diff = "diff", | ||
} | ||
declare enum Source { | ||
ltr = "ltr", | ||
rtl = "rtl", | ||
} | ||
declare enum Autorename { | ||
disabled = "disabled", | ||
flexible = "flexible", | ||
strict = "strict", | ||
} | ||
type ModeValues = keyof typeof Mode; | ||
type SourceValues = keyof typeof Source; | ||
type AutorenameValues = keyof typeof Autorename; | ||
type strings = string | string[]; | ||
interface PluginStringMap { | ||
name?: string; | ||
search: strings; | ||
replace: strings; | ||
} | ||
type PrefixSelectorTransformer = ( | ||
prefix: string, | ||
selector: string, | ||
) => string | void; | ||
export interface RTLCSSModuleOptions { | ||
mode?: ModeValues; | ||
ltrPrefix?: strings; | ||
rtlPrefix?: strings; | ||
bothPrefix?: strings; | ||
prefixSelectorTransformer?: PrefixSelectorTransformer; | ||
safeBothPrefix?: boolean; | ||
ignorePrefixedRules?: boolean; | ||
source?: SourceValues; | ||
processUrls?: boolean; | ||
processKeyFrames?: boolean; | ||
processEnv?: boolean; | ||
useCalc?: boolean; | ||
stringMap?: PluginStringMap[]; | ||
autoRename?: AutorenameValues; | ||
greedy?: boolean; | ||
aliases?: Record<string, string>; | ||
} |