UNPKG

vite-plugin-ruby

Version:

Convention over configuration for using Vite in Ruby apps

1 lines 21.6 kB
{"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/constants.ts","../src/config.ts","../src/manifest.ts"],"sourcesContent":["import { basename, posix, resolve } from 'path'\nimport { existsSync, readFileSync } from 'fs'\nimport type { ConfigEnv, PluginOption, UserConfig, ViteDevServer } from 'vite'\nimport createDebugger from 'debug'\n\nimport { cleanConfig, configOptionFromEnv } from './utils'\nimport { filterEntrypointsForRollup, loadConfiguration, resolveGlobs } from './config'\nimport { assetsManifestPlugin } from './manifest'\n\nexport * from './types'\n\n// Public: The resolved project root.\nexport const projectRoot = configOptionFromEnv('root') || process.cwd()\n\n// Internal: Additional paths to watch.\nlet watchAdditionalPaths: string[] = []\n\n// Public: Vite Plugin to detect entrypoints in a Ruby app, and allows to load a shared JSON configuration file that can be read from Ruby.\nexport default function ViteRubyPlugin (): PluginOption[] {\n return [\n {\n name: 'vite-plugin-ruby',\n config,\n configureServer,\n },\n assetsManifestPlugin(),\n ]\n}\n\nconst debug = createDebugger('vite-plugin-ruby:config')\n\n// Internal: Resolves the configuration from environment variables and a JSON\n// config file, and configures the entrypoints and manifest generation.\nfunction config (userConfig: UserConfig, env: ConfigEnv): UserConfig {\n const config = loadConfiguration(env.mode, projectRoot, userConfig)\n const { assetsDir, base, outDir, server, root, entrypoints, ssrBuild } = config\n\n const isLocal = config.mode === 'development' || config.mode === 'test'\n\n const rollupOptions = userConfig.build?.rollupOptions\n let rollupInput = rollupOptions?.input\n\n // Normalize any entrypoints provided by plugins.\n if (typeof rollupInput === 'string')\n rollupInput = { [rollupInput]: rollupInput }\n\n const build = {\n emptyOutDir: userConfig.build?.emptyOutDir ?? (ssrBuild || isLocal),\n sourcemap: !isLocal,\n ...userConfig.build,\n assetsDir,\n manifest: !ssrBuild,\n outDir,\n rollupOptions: {\n ...rollupOptions,\n input: {\n ...rollupInput,\n ...Object.fromEntries(filterEntrypointsForRollup(entrypoints)),\n },\n output: {\n ...outputOptions(assetsDir, ssrBuild),\n ...rollupOptions?.output,\n },\n },\n }\n\n const envDir = userConfig.envDir || projectRoot\n\n debug({ base, build, envDir, root, server, entrypoints: Object.fromEntries(entrypoints) })\n\n watchAdditionalPaths = resolveGlobs(projectRoot, root, config.watchAdditionalPaths || [])\n\n const alias = { '~/': `${root}/`, '@/': `${root}/` }\n\n return cleanConfig({\n resolve: { alias },\n base,\n envDir,\n root,\n server,\n build,\n viteRuby: config,\n })\n}\n\n// Internal: Allows to watch additional paths outside the source code dir.\nfunction configureServer (server: ViteDevServer) {\n server.watcher.add(watchAdditionalPaths)\n\n return () => server.middlewares.use((req, res, next) => {\n if (req.url === '/index.html' && !existsSync(resolve(server.config.root, 'index.html'))) {\n res.statusCode = 404\n const file = readFileSync(resolve(__dirname, 'dev-server-index.html'), 'utf-8')\n res.end(file)\n }\n\n next()\n })\n}\n\nfunction outputOptions (assetsDir: string, ssrBuild: boolean) {\n // Internal: Avoid nesting entrypoints unnecessarily.\n const outputFileName = (ext: string) => ({ name }: { name: string }) => {\n const shortName = basename(name).split('.')[0]\n return posix.join(assetsDir, `${shortName}-[hash].${ext}`)\n }\n\n return {\n assetFileNames: ssrBuild ? undefined : outputFileName('[ext]'),\n entryFileNames: ssrBuild ? undefined : outputFileName('js'),\n }\n}\n","import { readFileSync } from 'fs'\n\nimport { ENV_PREFIX } from './constants'\n\n// Internal: Replace Windows-style separators with POSIX-style separators.\nexport function slash (path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\n// Internal: Returns true if the specified value is a plain JS object\nexport function isObject (value: unknown): value is Record<string, any> {\n return Object.prototype.toString.call(value) === '[object Object]'\n}\n\n// Internal: Simplistic version that gets the job done for this scenario.\n// Example: screamCase('buildOutputDir') === 'BUILD_OUTPUT_DIR'\nexport function screamCase (key: string) {\n return key.replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase()\n}\n\n// Internal: Returns a configuration option that was provided using env vars.\nexport function configOptionFromEnv (optionName: string) {\n return process.env[`${ENV_PREFIX}_${screamCase(optionName)}`]\n}\n\n// Internal: Ensures it's easy to turn off a setting with env vars.\nexport function booleanOption<T> (value: 'true' | 'false' | boolean | T): boolean | T {\n if (value === 'true') return true\n if (value === 'false') return false\n return value\n}\n\n// Internal: Loads a json configuration file.\nexport function loadJsonConfig<T> (filepath: string): T {\n return JSON.parse(readFileSync(filepath, { encoding: 'utf8', flag: 'r' })) as T\n}\n\n// Internal: Removes any keys with undefined or null values from the object.\nexport function cleanConfig (object: Record<string, any>) {\n Object.keys(object).forEach((key) => {\n const value = object[key]\n if (value === undefined || value === null) delete object[key]\n else if (isObject(value)) cleanConfig(value)\n })\n return object\n}\n","// Internal: Inferred mode, since Vite doesn't yet expose it to its plugins.\nexport const APP_ENV = process.env.RAILS_ENV || process.env.RACK_ENV || process.env.APP_ENV\n\n// Internal: Prefix used for environment variables that modify the configuration.\nexport const ENV_PREFIX = 'VITE_RUBY'\n\n// Internal: Key of the vite.json file that is applied to all environments.\nexport const ALL_ENVS_KEY = 'all'\n\n// Internal: Extensions of CSS files or known precompilers.\nexport const KNOWN_CSS_EXTENSIONS = [\n 'css',\n 'less',\n 'sass',\n 'scss',\n 'styl',\n 'stylus',\n 'pcss',\n 'postcss',\n]\n\n// Internal: Types of files that Vite should process correctly as entrypoints.\nexport const KNOWN_ENTRYPOINT_TYPES = [\n 'html',\n 'jsx?',\n 'tsx?',\n ...KNOWN_CSS_EXTENSIONS,\n]\n\nexport const ENTRYPOINT_TYPES_REGEX = new RegExp(\n `\\\\.(${KNOWN_ENTRYPOINT_TYPES.join('|')})(\\\\?.*)?$`,\n)\n","import { join, relative, resolve } from 'path'\nimport glob from 'fast-glob'\n\nimport type { UserConfig, ServerOptions } from 'vite'\nimport { APP_ENV, ALL_ENVS_KEY, ENTRYPOINT_TYPES_REGEX } from './constants'\nimport { booleanOption, loadJsonConfig, configOptionFromEnv, slash } from './utils'\nimport { Config, ResolvedConfig, UnifiedConfig, MultiEnvConfig, Entrypoints } from './types'\n\n// Internal: Default configuration that is also read from Ruby.\nexport const defaultConfig: ResolvedConfig = loadJsonConfig(resolve(__dirname, '../default.vite.json'))\n\n// Internal: Returns the files defined in the entrypoints directory that should\n// be processed by rollup.\nexport function filterEntrypointsForRollup (entrypoints: Entrypoints): Entrypoints {\n return entrypoints\n .filter(([_name, filename]) => ENTRYPOINT_TYPES_REGEX.test(filename))\n}\n\n// Internal: Returns the files defined in the entrypoints directory that are not\n// processed by Rollup and should be manually fingerprinted and copied over.\nexport function filterEntrypointAssets (entrypoints: Entrypoints): Entrypoints {\n return entrypoints\n .filter(([_name, filename]) => !ENTRYPOINT_TYPES_REGEX.test(filename))\n}\n\n// Internal: Returns all files defined in the entrypoints directory.\nexport function resolveEntrypointFiles (projectRoot: string, sourceCodeDir: string, config: ResolvedConfig): Entrypoints {\n const inputGlobs = config.ssrBuild\n ? [config.ssrEntrypoint]\n : [`~/${config.entrypointsDir}/**/*`, ...config.additionalEntrypoints]\n\n const entrypointFiles = glob.sync(resolveGlobs(projectRoot, sourceCodeDir, inputGlobs))\n\n if (config.ssrBuild) {\n if (entrypointFiles.length === 0)\n throw new Error(`No SSR entrypoint available, please create \\`${config.ssrEntrypoint}\\` to do an SSR build.`)\n else if (entrypointFiles.length > 1)\n throw new Error(`Expected a single SSR entrypoint, found: ${entrypointFiles}`)\n\n return entrypointFiles.map(file => ['ssr', file])\n }\n\n return entrypointFiles.map((filename) => {\n let name = relative(sourceCodeDir, filename)\n if (name.startsWith('..'))\n name = relative(projectRoot, filename)\n\n return [name, filename]\n })\n}\n\n// Internal: Allows to use the `~` shorthand in the config globs.\nexport function resolveGlobs (projectRoot: string, sourceCodeDir: string, patterns: string[]) {\n return patterns.map(pattern =>\n slash(resolve(projectRoot, pattern.replace(/^~\\//, `${sourceCodeDir}/`))),\n )\n}\n\n// Internal: Loads configuration options provided through env variables.\nfunction configFromEnv (): Config {\n const envConfig: Record<string, any> = {}\n Object.keys(defaultConfig).forEach((optionName) => {\n const envValue = configOptionFromEnv(optionName)\n if (envValue !== undefined) envConfig[optionName] = envValue\n })\n return envConfig\n}\n\n// Internal: Allows to load configuration from a json file, and VITE_RUBY\n// prefixed environment variables.\nexport function loadConfiguration (viteMode: string, projectRoot: string, userConfig: UserConfig): UnifiedConfig {\n const envConfig = configFromEnv()\n const mode = envConfig.mode || APP_ENV || viteMode\n const filePath = join(projectRoot, envConfig.configPath || (defaultConfig.configPath as string))\n const multiEnvConfig = loadJsonConfig<MultiEnvConfig>(filePath)\n const fileConfig: Config = { ...multiEnvConfig[ALL_ENVS_KEY], ...multiEnvConfig[mode] }\n\n // Combine the three possible sources: env > json file > defaults.\n return coerceConfigurationValues({ ...defaultConfig, ...fileConfig, ...envConfig, mode }, projectRoot, userConfig)\n}\n\n// Internal: Coerces the configuration values and deals with relative paths.\nfunction coerceConfigurationValues (config: ResolvedConfig, projectRoot: string, userConfig: UserConfig): UnifiedConfig {\n // Coerce the values to the expected types.\n const port = config.port = parseInt(config.port as unknown as string)\n const https = config.https = userConfig.server?.https || booleanOption(config.https)\n\n const fs: ServerOptions['fs'] = { allow: [projectRoot], strict: userConfig.server?.fs?.strict ?? true }\n\n const server: ServerOptions = { fs, host: config.host, https, port, strictPort: true }\n\n if (booleanOption(config.skipProxy))\n server.origin = userConfig.server?.origin || `${https ? 'https' : 'http'}://${config.host}:${config.port}`\n\n // Connect directly to the Vite dev server, rack-proxy does not proxy websocket connections.\n const hmr = userConfig.server?.hmr ?? {}\n if (typeof hmr === 'object' && !hmr.hasOwnProperty('clientPort')) {\n hmr.clientPort ||= port\n server.hmr = hmr\n }\n\n // Use the sourceCodeDir as the Vite.js root.\n const root = join(projectRoot, config.sourceCodeDir)\n\n // Detect SSR builds and entrypoint provided via the --ssr flag.\n const ssrEntrypoint = userConfig.build?.ssr\n config.ssrBuild = Boolean(ssrEntrypoint)\n if (typeof ssrEntrypoint === 'string')\n config.ssrEntrypoint = ssrEntrypoint\n\n // Vite expects the outDir to be relative to the root.\n const outDir = relative(root, config.ssrBuild\n ? config.ssrOutputDir\n : join(config.publicDir, config.publicOutputDir))\n\n const base = resolveViteBase(config)\n const entrypoints = resolveEntrypointFiles(projectRoot, root, config)\n\n return { ...config, server, root, outDir, base, entrypoints }\n}\n\n// Internal: Configures Vite's base according to the asset host and publicOutputDir.\nexport function resolveViteBase ({ assetHost, base, publicOutputDir }: ResolvedConfig) {\n if (assetHost && !assetHost.startsWith('http')) assetHost = `//${assetHost}`\n\n return [\n ensureTrailingSlash(assetHost || base || '/'),\n publicOutputDir ? ensureTrailingSlash(slash(publicOutputDir)) : '',\n ].join('')\n}\n\nfunction ensureTrailingSlash (path: string) {\n return path.endsWith('/') ? path : `${path}/`\n}\n","import path from 'path'\nimport { promises as fsp } from 'fs'\nimport createDebugger from 'debug'\n\nimport type { Plugin, ResolvedConfig } from 'vite'\n\nimport type { OutputBundle, PluginContext } from 'rollup'\nimport { UnifiedConfig } from './types'\nimport { filterEntrypointAssets } from './config'\n\nconst debug = createDebugger('vite-plugin-ruby:assets-manifest')\n\ninterface AssetsManifestChunk {\n src?: string\n file: string\n}\n\ntype AssetsManifest = Map<string, AssetsManifestChunk>\n\n// Internal: Writes a manifest file that allows to map an entrypoint asset file\n// name to the corresponding output file name.\nexport function assetsManifestPlugin (): Plugin {\n let config: ResolvedConfig\n let viteRubyConfig: UnifiedConfig\n\n // Internal: Vite ignores some entrypoint assets, so we need to manually\n // fingerprint the files and move them to the output directory.\n async function fingerprintRemainingAssets (ctx: PluginContext, bundle: OutputBundle, manifest: AssetsManifest) {\n const remainingAssets = filterEntrypointAssets(viteRubyConfig.entrypoints)\n\n for (const [filename, absoluteFilename] of remainingAssets) {\n const content = await fsp.readFile(absoluteFilename)\n const ref = ctx.emitFile({ name: path.basename(filename), type: 'asset', source: content })\n const hashedFilename = ctx.getFileName(ref)\n manifest.set(path.relative(config.root, absoluteFilename), { file: hashedFilename, src: filename })\n }\n }\n\n return {\n name: 'vite-plugin-ruby:assets-manifest',\n apply: 'build',\n enforce: 'post',\n configResolved (resolvedConfig: ResolvedConfig) {\n config = resolvedConfig\n viteRubyConfig = (config as any).viteRuby\n },\n async generateBundle (_options, bundle) {\n if (!config.build.manifest) return\n\n const manifestDir = typeof config.build.manifest === 'string' ? path.dirname(config.build.manifest) : '.vite'\n const fileName = `${manifestDir}/manifest-assets.json`\n\n const manifest: AssetsManifest = new Map()\n await fingerprintRemainingAssets(this, bundle, manifest)\n debug({ manifest, fileName })\n\n this.emitFile({\n fileName,\n type: 'asset',\n source: JSON.stringify(Object.fromEntries(manifest), null, 2),\n })\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAAyC;AACzC,IAAAC,aAAyC;AAEzC,IAAAC,gBAA2B;;;ACH3B,gBAA6B;;;ACCtB,IAAM,UAAU,QAAQ,IAAI,aAAa,QAAQ,IAAI,YAAY,QAAQ,IAAI;AAG7E,IAAM,aAAa;AAGnB,IAAM,eAAe;AAGrB,IAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,IAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL;AAEO,IAAM,yBAAyB,IAAI;AAAA,EACxC,OAAO,uBAAuB,KAAK,GAAG,CAAC;AACzC;;;AD1BO,SAAS,MAAOC,OAAsB;AAC3C,SAAOA,MAAK,QAAQ,OAAO,GAAG;AAChC;AAGO,SAAS,SAAU,OAA8C;AACtE,SAAO,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AACnD;AAIO,SAAS,WAAY,KAAa;AACvC,SAAO,IAAI,QAAQ,mBAAmB,OAAO,EAAE,YAAY;AAC7D;AAGO,SAAS,oBAAqB,YAAoB;AACvD,SAAO,QAAQ,IAAI,GAAG,UAAU,IAAI,WAAW,UAAU,CAAC,E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,QAAM,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,MAAM,GAAG,IAAI,IAAI;AAEnD,SAAO,YAAY;AAAA,IACjB,SAAS,EAAE,MAAM;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAUA;AAAA,EACZ,CAAC;AACH;AAGA,SAAS,gBAAiB,QAAuB;AAC/C,SAAO,QAAQ,IAAI,oBAAoB;AAEvC,SAAO,MAAM,OAAO,YAAY,IAAI,CAAC,KAAK,KAAK,SAAS;AACtD,QAAI,IAAI,QAAQ,iBAAiB,KAAC,2BAAW,sBAAQ,OAAO,OAAO,MAAM,YAAY,CAAC,GAAG;AACvF,UAAI,aAAa;AACjB,YAAM,WAAO,6BAAa,sBAAQ,WAAW,uBAAuB,GAAG,OAAO;AAC9E,UAAI,IAAI,IAAI;AAAA,IACd;AAEA,SAAK;AAAA,EACP,CAAC;AACH;AAEA,SAAS,cAAe,WAAmB,UAAmB;AAE5D,QAAM,iBAAiB,CAAC,QAAgB,CAAC,EAAE,KAAK,MAAwB;AACtE,UAAM,gBAAY,uBAAS,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC;AAC7C,WAAO,mBAAM,KAAK,WAAW,GAAG,SAAS,WAAW,GAAG,EAAE;AAAA,EAC3D;AAEA,SAAO;AAAA,IACL,gBAAgB,WAAW,SAAY,eAAe,OAAO;AAAA,IAC7D,gBAAgB,WAAW,SAAY,eAAe,IAAI;AAAA,EAC5D;AACF;","names":["import_path","import_fs","import_debug","path","projectRoot","config","glob","path","import_path","import_fs","createDebugger","config","fsp","path","debug","createDebugger","config"]}