Skip to content

Instantly share code, notes, and snippets.

@igmoweb
Created April 28, 2017 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igmoweb/689377462c96113cfcfd5279e9074ece to your computer and use it in GitHub Desktop.
Save igmoweb/689377462c96113cfcfd5279e9074ece to your computer and use it in GitHub Desktop.
Webpack with development/production configs
const path = require( 'path' );
// Configuración común para desarrollo y producción
var config = {
entry: [
'./src/index.js'
],
output: {
filename: 'app.js',
path: path.resolve( __dirname, 'build' )
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
options: {
presets: [ 'es2015', 'react' ]
},
include: [
path.resolve( __dirname, 'src/' )
]
}
]
}
};
// module.exports ahora es una función que recibe la variable env
module.exports = function( env ) {
var production = 'prod' === env;
if ( production ) {
config.devtool = 'source-map';
}
else {
config.devtool = 'cheap-module-eval-source-map';
}
// ¡No olvidar retornar el objecto config!
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment