Skip to content

Commit

Permalink
Fix astro module on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Machy8 committed Mar 2, 2023
1 parent 444661c commit 74372cc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"dependencies": {
"@stylify/unplugin": "^0.5.27",
"loader-utils": "^2.0"
"normalize-path": "^3.0.0"
},
"devDependencies": {
"astro": "^1.1"
Expand Down
7 changes: 4 additions & 3 deletions packages/astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { UnpluginConfigInterface, stylifyVite, defineConfig as stylifyUnpluginCo
import { Configurator } from '@stylify/stylify';
import { fileURLToPath } from 'url';
import { join } from 'path';
import { default as normalize } from 'normalize-path';
import type { BundleConfigInterface } from '@stylify/bundler';

export const defineConfig = stylifyUnpluginConfig;
Expand All @@ -13,8 +14,8 @@ export const stylify = (options: UnpluginConfigInterface = {}): AstroIntegration
name: '@stylify/astro',
hooks: {
'astro:config:setup': ({ updateConfig, config, injectScript, command}): void => {
const srcDir = join(fileURLToPath(config.root), 'src');
const singleBundleOutputFilePath = join(srcDir, 'styles', 'stylify.css');
const srcDir: string = normalize(join(fileURLToPath(config.root), 'src'));
const singleBundleOutputFilePath: string = normalize(join(srcDir, 'styles', 'stylify.css'));
const isDev = options?.dev ?? (import.meta?.env?.DEV === true
|| import.meta?.env?.MODE === 'development'
|| command === 'dev'
Expand All @@ -39,7 +40,7 @@ export const stylify = (options: UnpluginConfigInterface = {}): AstroIntegration
? [{
outputFile: singleBundleOutputFilePath,
rewriteSelectorsInFiles: false,
files: [join(srcDir, `**`, `*.{astro,html,js,jsx,svelte,ts,tsx,vue}`)]
files: [`${srcDir}/**/*.{astro,html,js,jsx,svelte,ts,tsx,vue}`]
}]
: []
};
Expand Down
1 change: 1 addition & 0 deletions packages/bundler/src/Bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export class Bundler {
private addBundles(bundles: BundleConfigInterface[]) {
for (const bundle of bundles) {
const mangleSelectors = bundle?.compiler?.mangleSelectors ?? this.compilerConfig.mangleSelectors;
bundle.outputFile = normalize(bundle.outputFile);
const bundleToProcess = {
...bundle.outputFile in this.bundles ? this.bundles[bundle.outputFile] : {},
...bundle,
Expand Down
11 changes: 6 additions & 5 deletions packages/nuxt-module/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ export const defineConfig = (config: StylifyNuxtModuleConfigInterface): StylifyN
export default function Stylify(): void {
const { nuxt } = this;

const rootDir: string = nuxt.options.rootDir;
const pagesDir: string = nuxt.resolver.resolveAlias(nuxt.options.dir.pages);
const layoutsDir: string = nuxt.resolver.resolveAlias(nuxt.options.dir.layouts);
const componentsDir: string = nuxt.resolver.resolveAlias('components');
const contentDir: string = nuxt.resolver.resolveAlias('content');

moduleConfig.filesMasks = [
path.join(pagesDir, '**', '*.vue'),
path.join(layoutsDir, '**', '*.vue'),
path.join(componentsDir, '**', '*.vue'),
path.join(contentDir, '**', '*.vue'),
path.join(contentDir, '**', '*.md')
`${pagesDir}/**/*.vue`,
`${layoutsDir}/**/*.vue`,
`${componentsDir}/**/*.{vue,js,ts}`,
`${contentDir}/**/*.{vue,md}`,
`${rootDir}/plugins/**/*.{js,ts}`
];

moduleConfig.loaders = [
Expand Down

0 comments on commit 74372cc

Please sign in to comment.