1.0.0 • Published 4 years ago
ts-i18n-webpack-plugin v1.0.0
ts-i18n-webpack-plugin
Webpack plugin for running ts-i18n
Usage
Install the npm package:
npm i --save-dev ts-i18n-webpack-pluginWebpack
Add the plugin to your webpack.config.js
module.exports = {
plugins: [
new TsI18nWebpackPlugin({
inputDirectory: 'i18n/src',
outputDirectory: 'i18n/generated',
defaultLanguage: 'en'
})
...
]
...
}See the webpack and ts-i18n docs for more details.
Create React App (using Craco)
Install the npm packages:
npm i --save-dev ts-i18n-webpack-plugin @craco/cracoCreate a craco.config.js file with the following:
const TsI18nWebpackPlugin = require("ts-i18n-webpack-plugin");
module.exports = {
webpack: {
plugins: {
add: [
new TsI18nWebpackPlugin({
inputDirectory: 'i18n',
outputDirectory: 'src/i18n',
defaultLanguage: 'en',
}),
],
},
},
};Update your package.json file to replace the calls to react-scripts in scripts with craco:
{
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test"
...
}
...
}