{"id":20117,"library":"i18next-scanner-webpack","title":"i18next-scanner-webpack","description":"A webpack plugin that automatically extracts i18n translation keys from your source code using i18next-parser. Integrates with webpack 5.x and requires Node.js >= 14.16.0. Version 1.0.0 includes breaking changes from v0.9.0: replaced the underlying scanner with i18next-parser. The plugin scans specified file extensions for translation function calls like t() and generates locale JSON files. Supports both ESM and CommonJS configs, async mode for faster dev builds, and customizable lexers for different file types. Differentiators: simple setup, tight webpack integration, and active maintenance.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/ph1p/i18next-scanner-webpack","tags":["javascript","i18next","i18next-scanner","webpack","plugin","internationalization","i18n","localization"],"install":[{"cmd":"npm install i18next-scanner-webpack","lang":"bash","label":"npm"},{"cmd":"yarn add i18next-scanner-webpack","lang":"bash","label":"yarn"},{"cmd":"pnpm add i18next-scanner-webpack","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency — plugin is designed for Webpack 5.x","package":"webpack","optional":false},{"reason":"underlying scanner engine used for parsing translation keys","package":"i18next-parser","optional":false}],"imports":[{"note":"Default export. In CommonJS, use const I18nextWebpackPlugin = require('i18next-scanner-webpack') — NOT with .default.","wrong":"const I18nextWebpackPlugin = require('i18next-scanner-webpack').default","symbol":"I18nextWebpackPlugin","correct":"import I18nextWebpackPlugin from 'i18next-scanner-webpack'"},{"note":"Plugin options must be wrapped in an `options` object; locale configuration is part of the i18next-parser options.","wrong":"new I18nextWebpackPlugin({ locales: ['en', 'de'] })","symbol":"Constructor","correct":"new I18nextWebpackPlugin({ options: { locales: ['en', 'de'] } })"},{"note":"CJS module.exports is the plugin class directly, not a default export object.","wrong":"const I18nextWebpackPlugin = require('i18next-scanner-webpack').default","symbol":"CommonJS require","correct":"const I18nextWebpackPlugin = require('i18next-scanner-webpack')"}],"quickstart":{"code":"import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { dirname } from 'node:path';\nimport I18nextWebpackPlugin from 'i18next-scanner-webpack';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\nexport default {\n  mode: 'development',\n  entry: path.resolve(__dirname, './src/index.js'),\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: '[name].js'\n  },\n  plugins: [\n    new I18nextWebpackPlugin({\n      src: './src',\n      dest: './locales',\n      extensions: ['.js', '.jsx'],\n      options: {\n        lexers: {\n          js: [{\n            lexer: 'JavascriptLexer',\n            functions: ['t', '$t', 'i18next.t', 'i18n.t']\n          }]\n        },\n        locales: ['en', 'de'],\n        output: '$LOCALE/$NAMESPACE.json'\n      }\n    })\n  ]\n};","lang":"javascript","description":"Sets up i18next-scanner-webpack in webpack 5 with ESM config, scanning .js and .jsx files for translation keys, outputting English and German locale files."},"warnings":[{"fix":"Migrate config to use i18next-parser options (see v0.9.0 changelog). Example: replace `func` with `lexers`, `lngs` with `locales`, etc.","message":"v0.9.0 switched underlying scanner from i18next-scanner to i18next-parser. Config structure changed — options must now match i18next-parser format.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Upgrade to Webpack 5 if using v1.0.0+. For Webpack 4, use v0.8.3 or earlier.","message":"v1.0.0 requires Webpack 5.x. Earlier versions (0.x) may support Webpack 4.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Only use `async: true` in development mode. For production, set `async: false` (default).","message":"If `async` option is set to `true`, webpack may finish before translation files are written — be cautious in production builds.","severity":"gotcha","affected_versions":">=0.9.0"},{"fix":"Remove `.default` when requiring via CommonJS.","message":"CommonJS require without .default: `const Plugin = require('i18next-scanner-webpack')` works. Using `.default` will result in `undefined`.","severity":"gotcha","affected_versions":"*"},{"fix":"Update to v0.9.0+ and migrate config to i18next-parser format.","message":"Versions <=0.8.3 use deprecated i18next-scanner package. Configs from those versions are incompatible with v0.9.0+.","severity":"deprecated","affected_versions":"<=0.8.3"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install i18next-parser --save-dev` or check that it is in your dependencies.","cause":"Missing peer dependency i18next-parser when using v0.9.0+.","error":"Cannot find module 'i18next-parser'"},{"fix":"Use `const I18nextWebpackPlugin = require('i18next-scanner-webpack');` without `.default`.","cause":"Using `.default` on CommonJS require: `const Plugin = require('...').default` returns undefined.","error":"TypeError: I18nextWebpackPlugin is not a constructor"},{"fix":"Wrap i18next-parser options in an `options` property: `new I18nextWebpackPlugin({ options: { locales: ['en'] } })`.","cause":"Options not nested under `options` key in plugin config, e.g. `{ locales: ['en'] }` instead of `{ options: { locales: ['en'] } }`.","error":"Error: Configuration error. Cannot find 'options.locales'"},{"fix":"Add lexers for TypeScript: `options.lexers.ts: [{ lexer: 'JavascriptLexer', functions: ['t'] }]`.","cause":"TypeScript files not scanned by default; need lexer configuration.","error":"Error: Unsupported file extension '.ts'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}