cz-typography
Version:
Universal Czech typography fixer for JavaScript, React, Next.js, and any SSR framework. Non-breaking spaces after one-letter prepositions, units, dates, ordinals and more.
1 lines • 2.51 kB
Source Map (JSON)
{"version":3,"sources":["../../src/next/index.js"],"names":["dirname","fileURLToPath","resolve"],"mappings":";;;;;;;AAWO,SAAS,iBAAiB,UAAA,GAAa,EAAC,EAAG,aAAA,GAAgB,EAAC,EAAG;AAClE,EAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAS,OAAA,GAAU,gBAAe,GAAI,aAAA;AACvD,EAAA,MAAM,IAAA,GAAOA,YAAA,CAAQC,iBAAA,CAAc,2PAAe,CAAC,CAAA;AACnD,EAAA,MAAM,UAAA,GAAaC,YAAA,CAAQ,IAAA,EAAM,cAAc,CAAA;AAE/C,EAAA,OAAO;AAAA,IACH,GAAG,UAAA;AAAA,IACH,OAAA,CAAQ,eAAe,OAAA,EAAS;AAC5B,MAAA,aAAA,CAAc,SAAS,aAAA,CAAc,MAAA,IAAU,EAAE,KAAA,EAAO,EAAC,EAAE;AAC3D,MAAA,aAAA,CAAc,MAAA,CAAO,KAAA,GAAQ,aAAA,CAAc,MAAA,CAAO,SAAS,EAAC;AAC5D,MAAA,aAAA,CAAc,MAAA,CAAO,MAAM,IAAA,CAAK;AAAA,QAC5B,MAAM,OAAA,IAAW,gBAAA;AAAA,QACjB,OAAA;AAAA,QACA,GAAA,EAAK;AAAA,UACD;AAAA,YACI,MAAA,EAAQ,UAAA;AAAA,YACR,OAAA,EAAS,EAAE,OAAA;AAAQ;AACvB;AACJ,OACH,CAAA;AAED,MAAA,IAAI,OAAO,UAAA,CAAW,OAAA,KAAY,UAAA,EAAY;AAC1C,QAAA,OAAO,UAAA,CAAW,OAAA,CAAQ,aAAA,EAAe,OAAO,CAAA;AAAA,MACpD;AACA,MAAA,OAAO,aAAA;AAAA,IACX;AAAA,GACJ;AACJ","file":"index.cjs","sourcesContent":["import { fileURLToPath } from 'node:url';\r\nimport { dirname, resolve } from 'node:path';\r\n\r\n/**\r\n * Wrap a Next.js config so that source files are passed through the\r\n * cz-typography webpack loader at build time, rewriting static JSX text\r\n * literals.\r\n *\r\n * @param {object} nextConfig\r\n * @param {{ options?: import('../fixCzech.js').FixCzechOptions, include?: RegExp, exclude?: RegExp }} [loaderOptions]\r\n */\r\nexport function withCzTypography(nextConfig = {}, loaderOptions = {}) {\r\n const { options, include, exclude = /node_modules/ } = loaderOptions;\r\n const here = dirname(fileURLToPath(import.meta.url));\r\n const loaderPath = resolve(here, './loader.cjs');\r\n\r\n return {\r\n ...nextConfig,\r\n webpack(webpackConfig, context) {\r\n webpackConfig.module = webpackConfig.module || { rules: [] };\r\n webpackConfig.module.rules = webpackConfig.module.rules || [];\r\n webpackConfig.module.rules.push({\r\n test: include || /\\.(jsx?|tsx?)$/,\r\n exclude,\r\n use: [\r\n {\r\n loader: loaderPath,\r\n options: { options },\r\n },\r\n ],\r\n });\r\n\r\n if (typeof nextConfig.webpack === 'function') {\r\n return nextConfig.webpack(webpackConfig, context);\r\n }\r\n return webpackConfig;\r\n },\r\n };\r\n}\r\n\r\n"]}