Created
October 16, 2017 16:47
-
-
Save geovanisouza92/7ce07bf6141e1c353475af1caab85129 to your computer and use it in GitHub Desktop.
Keep modules for Webpack, transpile everything for Jest
This file contains hidden or 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
Show hidden characters
{ | |
"presets": ["./.babelrc.js"] | |
} |
This file contains hidden or 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
// Works like magic™ | |
// | |
// We point .babelrc to use this file as a preset, and here we could | |
// use regular Node.js code | |
// | |
// Reference: https://fatfisz.com/blog/using-babelrc-js-today | |
const modules = (/build/.test(process.env.npm_lifecycle_event)) ? false : 'commonjs' | |
const retainLines = !(/build/.test(process.env.npm_lifecycle_event)) | |
module.exports = { | |
presets: [ | |
['env', { | |
modules, | |
targets: { | |
node: '4.3' | |
} | |
}] | |
], | |
plugins: ['preval', 'transform-object-rest-spread'], | |
retainLines | |
} |
This file contains hidden or 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
module.exports = { | |
// ... | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: /node_modules/, | |
use: 'babel-loader' | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment