Skip to content

Commit

Permalink
Add polyfills to react template (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
tar-g authored Apr 23, 2019
1 parent 8488440 commit 1a174ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions commands/application.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const addTemplate = (appPath, appName, templateOptions) => {
const templateSourcePath = path.join(__dirname, '..', 'templates', 'react', 'application');
const packagePath = path.join(appPath, 'package.json');
const manifestPath = path.join(appPath, 'public', 'manifest.json');
const indexPath = path.join(appPath, 'src', 'index.js');
const styles = [
'devextreme/dist/css/dx.common.css',
'./themes/generated/theme.additional.css',
Expand All @@ -112,6 +113,7 @@ const addTemplate = (appPath, appName, templateOptions) => {
}
preparePackageJsonForTemplate(packagePath, appName);
updateJsonPropName(manifestPath, appName);
addPolyfills(packagePath, indexPath);
install({}, appPath, styles);
};

Expand All @@ -124,6 +126,15 @@ const install = (options, appPath, styles) => {
runCommand('npm', ['install'], { cwd: appPath });
};

const addPolyfills = (packagePath, indexPath) => {
const packages = [
{ name: 'react-app-polyfill', version: '^1.0.0' }
];

packageJsonUtils.addDependencies(packagePath, packages);
moduleUtils.insertImport(indexPath, './polyfills');
};

const addStylesToApp = (filePath, styles) => {
styles.forEach(style => {
moduleUtils.insertImport(filePath, style);
Expand Down
2 changes: 2 additions & 0 deletions templates/react/application/src/polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

0 comments on commit 1a174ac

Please sign in to comment.