1.2.0 • Published 5 years ago

@reflexions/drupal-gutenberg-translations-webpack-plugin v1.2.0

Weekly downloads
31
License
MIT
Repository
github
Last release
5 years ago

DrupalGutenbergTranslationsPlugin

A Webpack plugin for generating Drupal translations for Gutenberg modules.

Setup

yarn add --dev @reflexions/drupal-gutenberg-translations-webpack-plugin
const path = require('path');
const DrupalGutenbergTranslationsWebpackPlugin = require('@reflexions/drupal-gutenberg-translations-webpack-plugin');
...
plugins: [
	new DrupalGutenbergTranslationsPlugin({
		path: path.resolve(__dirname, 'js'), // path to the directory containing translateable files
		bin: path.resolve('/bin', 'drupal-gutenberg-tranlations'), // OPTIONAL path to the translation bin
	}),
],

If your code optimizer is mangling variable names, you may need to prevent that in order for the translation tool to find translations. Add the following code to your webpack config to prevent the translation var from being mangled:

// A similar option is also available for the UglifyPlugin if you choose to use that instead
const TerserPlugin = require('terser-webpack-plugin');
...
optimization: {
	minimize: process.env.NODE_ENV === 'production',
	minimizer: [new TerserPlugin({
		terserOptions: {
			mangle: {
				reserved: [ '__' ],
			},
		},
	})],
},
1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago