UNPKG

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.

37 lines (34 loc) 1.39 kB
'use strict'; var url = require('url'); var path = require('path'); var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; // src/next/index.js function withCzTypography(nextConfig = {}, loaderOptions = {}) { const { options, include, exclude = /node_modules/ } = loaderOptions; const here = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)))); const loaderPath = path.resolve(here, "./loader.cjs"); return { ...nextConfig, webpack(webpackConfig, context) { webpackConfig.module = webpackConfig.module || { rules: [] }; webpackConfig.module.rules = webpackConfig.module.rules || []; webpackConfig.module.rules.push({ test: include || /\.(jsx?|tsx?)$/, exclude, use: [ { loader: loaderPath, options: { options } } ] }); if (typeof nextConfig.webpack === "function") { return nextConfig.webpack(webpackConfig, context); } return webpackConfig; } }; } exports.withCzTypography = withCzTypography; //# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map