Upgrade project structure to webpack 4.

Remove unused dependencies.
Rename all .jsx files into .js.
This commit is contained in:
ErickSkrauch
2019-03-17 01:37:00 +03:00
parent 1f102b71b0
commit cb84df8f96
29 changed files with 2890 additions and 2298 deletions

View 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})
`;
};

View File

@@ -0,0 +1,7 @@
{
"name": "intl-json-loader",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
}
}

View File

@@ -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 + ')';
};

View File

@@ -1,10 +0,0 @@
{
"name": "webpack-utils",
"version": "1.0.0",
"description": "",
"keywords": [],
"author": "",
"dependencies": {
"loader-utils": "^0.2.12"
}
}