marcusshepp
8/12/2016 - 2:48 PM

webpack config

webpack config

// simple in-out
module.exports = {
  entry: `${__dirname}/src/app.js`,
  output: {
    path: `${__dirname}/dist`,
    filename: 'bundle.js'
  },
}

// loaders/transpilers/webpack-dev-server
module.exports = {
	entry: './src/app.js',
	output: {
		path: './bin',
		filename: 'bundle.js'
	},
	module: {
		loaders: [
		{
			test: /\.js$/,
			loaders: ['babel?presets[]=react,presets[]=es2015'],
			exclude: /node_modules/,
		}
		]
	}
}



// with loaders/transpilers
module.exports = {
  entry: `${__dirname}/src/app.js`,
  output: {
    path: `${__dirname}/dist`,
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      {
        // test and load files with `.js` extention
        test: /\.js$/, 
        loader: 'babel',
        query: {
          // what to transpile to, bc babel does 
          // not transpile into es6 by default
          presets: ['es2015'] 
        }
      }
    ]
  }
}

// config for webpack-dev-server
var webpack = require('webpack');
var path = require('path');

module.exports = {

    devtool: 'inline-source-map',
    entry: [
        'webpack-dev-server/client?http://localhost:8080',
        'webpack/hot/only-dev-server',
        './src' // no file name specified, defaults to index.js
    ],
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'bundle.js',
    },
    resolve: {
        modulesDirectories: ['node_modules', 'src'],
        extensions: ['', '.js']
    },
    module: {
        loaders: [
        {
            test: /\.jsx?$/,
            exclude: /node_modules/,
            loaders: ['react-hot', 'babel?presets[]=react,presets[]=es2015']
        }
        ]
    },
    plugins: [
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin(),
    ]

}