Skip to content

Instantly share code, notes, and snippets.

@martiuh
Last active February 13, 2017 20:49
Show Gist options
  • Save martiuh/2bd801eeacccfd3e9dc113c0ceac75f5 to your computer and use it in GitHub Desktop.
Save martiuh/2bd801eeacccfd3e9dc113c0ceac75f5 to your computer and use it in GitHub Desktop.
var webpack = require('webpack')
//En lugar de usar un archivo .babelrc, agregamos la configuración de babelQuery aquí
var babelQuery = {presets: ["react", "es2015"], plugins:[]};
var webpackConfig = {
entry: './app/mainEntry.js',
output: {
path: "./public",
filename: 'bundle.js'
},
module: {
loaders:[
{
test: /\.js$/,
exclude: /node_modules/,
loader:"babel",
//BORRAME: Agregamos la babelQuery
query: babelQuery
}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
}
}
if (process.env.NODE_ENV === 'production') {
//El SourceMap más simple que se puede hacer, sin columnas de mapeo, sino simple líneas
webpackConfig.devtool = 'cheap-module-source-map'
// Este plugin es para que todos los módulos de node_modules se lean con la variable NODE_ENV = production
// y no manden las alertas de desarrollo
webpackConfig.plugins.push(new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
})
);
//Ignoramos ayudas para IE8
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true
}
})
);
/*
transform-react-inline-elements
Esto sólo es necesario si utilizamos la forma
class App extends React.Component {
render() {
return (
<h1>Soy App </h1>
)
}
}
Ya que hace una versión optimizada del código mucho mejor que React.createClass
transform-react-constant-elements
Reduce los llamados a React.createElement, evita repeticiones
*/
babelQuery.plugins.push("transform-react-inline-elements","transform-react-constant-elements");
}
module.exports = webpackConfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment