{"record":{"id":"fa3ed6511a6532f0","repo":"laurent22/joplin","slug":"a-config-file-must-be-specified-via-the-joplin-p","errorCode":null,"errorMessage":"A config file must be specified via the --joplin-plugin-config flag","messagePattern":"A config file must be specified via the --joplin-plugin-config flag","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/generator-joplin/generators/app/templates/webpack.config.js","lineNumber":348,"sourceCode":"const updateVersion = () => {\n\tconst packageJson = getPackageJson();\n\tpackageJson.version = increaseVersion(packageJson.version);\n\tfs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\\n`, 'utf8');\n\n\tconst manifest = readManifest(manifestPath);\n\tmanifest.version = increaseVersion(manifest.version);\n\twriteManifest(manifestPath, manifest);\n\n\tif (packageJson.version !== manifest.version) {\n\t\tconsole.warn(chalk.yellow(`Version numbers have been updated but they do not match: package.json (${packageJson.version}), manifest.json (${manifest.version}). Set them to the required values to get them in sync.`));\n\t} else {\n\t\tconsole.info(packageJson.version);\n\t}\n};\n\nfunction main(environ) {\n\tconst configName = environ['joplin-plugin-config'];\n\tif (!configName) throw new Error('A config file must be specified via the --joplin-plugin-config flag');\n\n\t// Webpack configurations run in parallel, while we need them to run in\n\t// sequence, and to do that it seems the only way is to run webpack multiple\n\t// times, with different config each time.\n\n\tconst configs = {\n\t\t// Builds the main src/index.ts and copy the extra content from /src to\n\t\t// /dist including scripts, CSS and any other asset.\n\t\tbuildMain: [pluginConfig],\n\n\t\t// Builds the extra scripts as defined in plugin.config.json. When doing\n\t\t// so, some JavaScript files that were copied in the previous might be\n\t\t// overwritten here by the compiled version. This is by design. The\n\t\t// result is that JS files that don't need compilation, are simply\n\t\t// copied to /dist, while those that do need it are correctly compiled.\n\t\tbuildExtraScripts: buildExtraScriptConfigs(userConfig),\n\n\t\t// Ths config is for creating the .jpl, which is done via the plugin, so","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/laurent22/joplin/blob/2654b33620775080d1d59c552259d41e33dad3d2/packages/generator-joplin/generators/app/templates/webpack.config.js#L330-L366","documentation":"Thrown by main() in the generated webpack.config.js when the webpack `env` object has no `joplin-plugin-config` key. This flag selects which webpack config to run (buildMain vs buildExtraScripts); without it the runner cannot decide. The template expects it to be injected by the plugin's npm scripts.","triggerScenarios":"webpack is invoked without the env flag — e.g. calling `webpack` directly, or a custom script that omits `--env joplin-plugin-config=...`.","commonSituations":"Author replaced the scaffolded npm scripts; running webpack-dev-server without the flag; upgraded tooling that swallowed the env argument.","solutions":["Use the npm scripts provided by the scaffold (e.g. `npm run build` / `npm run dist`) which pass the flag for you.","If invoking webpack directly, add `--env joplin-plugin-config=dev` (or `prod`).","Check package.json scripts were not overwritten and still pass the flag."],"exampleFix":"// before (custom command)\nwebpack --config webpack.config.js\n// after\nwebpack --env joplin-plugin-config=dev --config webpack.config.js","handlingStrategy":"validation","validationCode":"// In a wrapper script, ensure the env flag is present before invoking webpack.\nconst configName = process.env.JOPLIN_PLUGIN_CONFIG || (process.argv.includes('--joplin-plugin-config') ? process.argv[process.argv.indexOf('--joplin-plugin-config') + 1] : null);\nif (!configName) throw new Error('Missing --joplin-plugin-config=dev|prod');","typeGuard":"const hasConfigFlag = (argv) => argv.some(a => a.startsWith('--joplin-plugin-config')) || argv.some(a => a.startsWith('--env') && a.includes('joplin-plugin-config'));","tryCatchPattern":"try { main(env); }\ncatch (e) { if (/joplin-plugin-config flag/.test(e.message)) { /* print usage and exit */ } else throw e; }","preventionTips":["Rely on the scaffold's npm scripts rather than calling webpack directly.","If you customise the build, propagate --env joplin-plugin-config=<dev|prod> in every webpack invocation."],"tags":["plugin-build","webpack","build-config","generator-joplin"],"backgroundTag":null,"analyzedSha":"2654b33620775080d1d59c552259d41e33dad3d2","analyzedAt":"2026-08-12T14:26:46.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}