Permalink
Browse files

add webpack and babel config files

  • Loading branch information...
1 parent 14ad547 commit e59a40e6528929ebe357016de6920d4b60070602 @Siddharth11 committed Nov 10, 2016
Showing with 76 additions and 0 deletions.
  1. +3 −0 .babelrc
  2. +73 −0 webpack.config.js
View
@@ -0,0 +1,3 @@
+{
+ "presets": ["es2015", "react"]
+}
View
@@ -0,0 +1,73 @@
+const webpack = require('webpack')
+const ExtractTextPlugin = require('extract-text-webpack-plugin')
+const CleanPlugin = require('clean-webpack-plugin')
+const cssnext = require('postcss-cssnext')
+
+const production = process.env.NODE_ENV === 'production';
+
+let plugins = [
+ new ExtractTextPlugin("bundle.css")
+]
+
+if (production) {
+ plugins = plugins.concat([
+
+ new CleanPlugin('./client/dist/assets'),
+
+ // This plugin looks for similar chunks and files
+ // and merges them for better caching by the user
+ new webpack.optimize.DedupePlugin(),
+
+ // This plugins optimizes chunks and modules by
+ // how much they are used in your app
+ new webpack.optimize.OccurenceOrderPlugin(),
+
+ // This plugin minifies all the Javascript code of the final bundle
+ new webpack.optimize.UglifyJsPlugin({
+ mangle: true,
+ compress: {
+ warnings: false, // Suppress uglification warnings
+ },
+ }),
+
+ // This plugins defines various variables that we can set to false
+ // in production to avoid code related to them from being compiled
+ // in our final bundle
+ new webpack.DefinePlugin({
+ __SERVER__: !production,
+ __DEVELOPMENT__: !production,
+ __DEVTOOLS__: !production,
+ 'process.env': {
+ BABEL_ENV: JSON.stringify(process.env.NODE_ENV),
+ NODE_ENV: JSON.stringify(process.env.NODE_ENV),
+ },
+ }),
+
+ ]);
+}
+
+module.exports = {
+ debug: !production,
+ devtool: production ? false : 'source-map',
+ entry: './client/src/js/main.js',
+ output: {
+ path: './client/dist/assets',
+ filename: 'bundle.js'
+ },
+ module: {
+ loaders: [
+ {
+ test: /\.js/,
+ exclude: /node_modules/,
+ loader: 'babel',
+ include: __dirname + '/client/src/js/',
+ },
+ {
+ test: /\.scss/,
+ loader: ExtractTextPlugin.extract("style", "css!postcss!sass")
+ }
+ ]
+ },
+ postcss: [cssnext],
+ plugins: plugins
+}

0 comments on commit e59a40e

Please sign in to comment.