Skip to content

Instantly share code, notes, and snippets.

@geovanisouza92
Created October 16, 2017 16:47
Show Gist options
  • Save geovanisouza92/7ce07bf6141e1c353475af1caab85129 to your computer and use it in GitHub Desktop.
Save geovanisouza92/7ce07bf6141e1c353475af1caab85129 to your computer and use it in GitHub Desktop.
Keep modules for Webpack, transpile everything for Jest
{
"presets": ["./.babelrc.js"]
}
// 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
}
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