-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02c7b4e
commit a94f800
Showing
10 changed files
with
7,470 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,44 @@ | ||
# parcel-plugin-localization-bundler | ||
# 📦🚀 parcel-plugin-localization-bundler | ||
|
||
A plugin that bundles localization files into one bundle per namespace and language | ||
|
||
The structur must be `${language}/${namespace}/localeFile.json` | ||
|
||
Eg. the following locale structur | ||
|
||
``` | ||
/en/pages.json | ||
/en/pages/1.json | ||
/en/pages/2.json | ||
/en/pages/3.json | ||
/en/plugins.json | ||
/en/plugins/1.json | ||
/en/plugins/2.json | ||
/en/plugins/3.json | ||
/de/pages.json | ||
/de/pages/1.json | ||
/de/pages/2.json | ||
/de/pages/3.json | ||
/de/plugins.json | ||
/de/plugins/1.json | ||
/de/plugins/2.json | ||
/de/plugins/3.json | ||
``` | ||
Would result in 4 bundles, one for each namespace; `pages` and `plugins`, and one for each language of the given namespace, `en` and `de`. | ||
|
||
# Setup | ||
|
||
``` | ||
npm i parcel-plugin-localization-bundler | ||
``` | ||
|
||
There must be a `parcel-plugin-localization-bundler` section in your `package.json`, containing: | ||
```json | ||
... | ||
"parcel-plugin-localization-bundler": { | ||
"entryFile": "index.tsx", | ||
"sourcePath": "localizations" | ||
} | ||
... | ||
``` | ||
The entryFile determines which file in your project that the new bundles should be dynamic dependencies of. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const getConfig = require("./src/helpers/getConfig") | ||
const logger = require('@parcel/logger') | ||
|
||
module.exports = async bundler => { | ||
const config = await getConfig(bundler.options.rootDir) | ||
if (config) { | ||
bundler.addAssetType('js', require.resolve('./src/JSAsset')) | ||
bundler.addAssetType('json', require.resolve('./src/JSONAsset')) | ||
} else { | ||
logger.error(`[parcel-plugin-localization-bundler]: Missing configuration in package.json`) | ||
} | ||
} |
Oops, something went wrong.