Skip to content

Commit 1a174ac

Browse files
authored
Add polyfills to react template (#74)
1 parent 8488440 commit 1a174ac

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

commands/application.react.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const addTemplate = (appPath, appName, templateOptions) => {
101101
const templateSourcePath = path.join(__dirname, '..', 'templates', 'react', 'application');
102102
const packagePath = path.join(appPath, 'package.json');
103103
const manifestPath = path.join(appPath, 'public', 'manifest.json');
104+
const indexPath = path.join(appPath, 'src', 'index.js');
104105
const styles = [
105106
'devextreme/dist/css/dx.common.css',
106107
'./themes/generated/theme.additional.css',
@@ -112,6 +113,7 @@ const addTemplate = (appPath, appName, templateOptions) => {
112113
}
113114
preparePackageJsonForTemplate(packagePath, appName);
114115
updateJsonPropName(manifestPath, appName);
116+
addPolyfills(packagePath, indexPath);
115117
install({}, appPath, styles);
116118
};
117119

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

129+
const addPolyfills = (packagePath, indexPath) => {
130+
const packages = [
131+
{ name: 'react-app-polyfill', version: '^1.0.0' }
132+
];
133+
134+
packageJsonUtils.addDependencies(packagePath, packages);
135+
moduleUtils.insertImport(indexPath, './polyfills');
136+
};
137+
127138
const addStylesToApp = (filePath, styles) => {
128139
styles.forEach(style => {
129140
moduleUtils.insertImport(filePath, style);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import 'react-app-polyfill/ie11';
2+
import 'react-app-polyfill/stable';

0 commit comments

Comments
 (0)