mirror of
https://github.com/elyby/emails-renderer.git
synced 2025-05-31 14:12:05 +05:30
Upgrade project structure to webpack 4.
Remove unused dependencies. Rename all .jsx files into .js.
This commit is contained in:
25
webpack-utils/intl-json-loader/index.js
Normal file
25
webpack-utils/intl-json-loader/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function(input) {
|
||||
this.cacheable && this.cacheable();
|
||||
|
||||
const moduleId = this.context
|
||||
.replace(path.join(this.rootContext, 'src'), '')
|
||||
.replace(/^\/|\/$/g, '')
|
||||
.replace(/\//g, '.');
|
||||
|
||||
const json = JSON.parse(input);
|
||||
const result = JSON.stringify(Object.keys(json).reduce((translations, key) => {
|
||||
translations[key] = {
|
||||
id: `${moduleId}.${key}`,
|
||||
defaultMessage: json[key],
|
||||
};
|
||||
|
||||
return translations;
|
||||
}, {}));
|
||||
|
||||
return `
|
||||
import { defineMessages } from 'react-intl';
|
||||
export default defineMessages(${result})
|
||||
`;
|
||||
};
|
||||
7
webpack-utils/intl-json-loader/package.json
Normal file
7
webpack-utils/intl-json-loader/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "intl-json-loader",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
module.exports = function() {
|
||||
this.cacheable && this.cacheable();
|
||||
|
||||
var moduleId = this.context
|
||||
.replace(this.options.resolve.root, '')
|
||||
.replace(/^\/|\/$/g, '')
|
||||
.replace(/\//g, '.');
|
||||
|
||||
var content = this.inputValue[0];
|
||||
content = JSON.stringify(Object.keys(content).reduce(function(translations, key) {
|
||||
translations[key] = {
|
||||
id: moduleId + '.' + key,
|
||||
defaultMessage: content[key]
|
||||
};
|
||||
|
||||
return translations;
|
||||
}, {}));
|
||||
|
||||
return 'import { defineMessages } from \'react-intl\';'
|
||||
+ 'export default defineMessages(' + content + ')';
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "webpack-utils",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"loader-utils": "^0.2.12"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user