-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add babel and postcss configs to templates
- Loading branch information
1 parent
588b41f
commit a0b0ec4
Showing
4 changed files
with
84 additions
and
280 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
module.exports = function() { | ||
const validEnv = ['development', 'test', 'production'] | ||
const currentEnv = process.env["NODE_ENV"] | ||
const isDevelopmentEnv = (currentEnv === "development") | ||
const isProductionEnv = (currentEnv === 'production') | ||
const isTestEnv = (currentEnv === 'test') | ||
|
||
if (!validEnv.includes(currentEnv)) { | ||
throw new Error( | ||
'Please specify a valid `NODE_ENV` or ' + | ||
'`BABEL_ENV` environment variables. Valid values are "development", ' + | ||
'"test", and "production". Instead, received: ' + | ||
JSON.stringify(currentEnv) + | ||
'.' | ||
) | ||
} | ||
|
||
return { | ||
presets: [ | ||
isTestEnv && [ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
node: 'current' | ||
} | ||
} | ||
], | ||
(isProductionEnv || isDevelopmentEnv) && [ | ||
'@babel/preset-env', | ||
{ | ||
forceAllTransforms: true, | ||
useBuiltIns: 'entry', | ||
corejs: 3, | ||
modules: false, | ||
exclude: ['transform-typeof-symbol'] | ||
} | ||
] | ||
].filter(Boolean), | ||
plugins: [ | ||
'babel-plugin-macros', | ||
'@babel/plugin-syntax-dynamic-import', | ||
isTestEnv && 'babel-plugin-dynamic-import-node', | ||
'@babel/plugin-transform-destructuring', | ||
[ | ||
'@babel/plugin-proposal-class-properties', | ||
{ | ||
loose: true | ||
} | ||
], | ||
[ | ||
'@babel/plugin-proposal-object-rest-spread', | ||
{ | ||
useBuiltIns: true | ||
} | ||
], | ||
[ | ||
'@babel/plugin-transform-runtime', | ||
{ | ||
helpers: false, | ||
regenerator: true, | ||
corejs: false | ||
} | ||
], | ||
[ | ||
'@babel/plugin-transform-regenerator', | ||
{ | ||
async: false | ||
} | ||
] | ||
].filter(Boolean) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
plugins: [ | ||
require('postcss-import'), | ||
require('postcss-flexbugs-fixes'), | ||
require('postcss-preset-env')({ | ||
autoprefixer: { | ||
flexbox: 'no-2009' | ||
}, | ||
stage: 3 | ||
}) | ||
] | ||
} |