Skip to content

Commit

Permalink
feat: use modern browser target during dev
Browse files Browse the repository at this point in the history
This speeds up development hot-reload time.

Closes #12
  • Loading branch information
swashata committed Oct 20, 2018
1 parent 31d8635 commit ed5edb1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ Object {
"@wpackio/base",
Object {
"hasReact": true,
"presetEnv": Object {
"targets": Object {
"chrome": "69",
"edge": "17",
"firefox": "62",
},
},
},
],
],
Expand All @@ -60,6 +67,13 @@ Object {
"@wpackio/base",
Object {
"hasReact": true,
"presetEnv": Object {
"targets": Object {
"chrome": "69",
"edge": "17",
"firefox": "62",
},
},
},
],
Array [
Expand Down
19 changes: 17 additions & 2 deletions packages/scripts/src/config/WebpackConfigHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,27 @@ ${bannerConfig.copyrightText}${bannerConfig.credit ? creditNote : ''}`,
*/
public getModule(): webpack.Module {
const { hasReact, hasSass, hasFlow } = this.config;
const wpackioBabelOptions: PresetOptions = {
hasReact,
};
// Push targets to babel-preset-env if this is dev
// We target only the latest chrome and firefox for
// greater speed
if (this.isDev) {
wpackioBabelOptions.presetEnv = {
targets: {
chrome: '69',
firefox: '62',
edge: '17',
},
};
}
// create the babel rules for es6+ code
const jsPresets: babelPreset[] = [
[
'@wpackio/base',
this.getBabelPresetOptions(
{ hasReact },
wpackioBabelOptions,
this.config.jsBabelPresetOptions
),
],
Expand Down Expand Up @@ -343,7 +358,7 @@ ${bannerConfig.copyrightText}${bannerConfig.credit ? creditNote : ''}`,
[
'@wpackio/base',
this.getBabelPresetOptions(
{ hasReact },
wpackioBabelOptions,
this.config.tsBabelPresetOptions
),
],
Expand Down

0 comments on commit ed5edb1

Please sign in to comment.