webpack.config.dev.js 1.36 KB
Newer Older
Dan Abramov's avatar
Dan Abramov committed
1
2
3
4
5
6
var path = require('path');
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
7
8
9
10
11
  devtool: 'eval',
  entry: [
    './src/index.js',
    'webpack-dev-server/client?http://localhost:3000'
  ],
Dan Abramov's avatar
Dan Abramov committed
12
13
14
15
16
17
18
  output: {
    // Next line is not used in dev but WebpackDevServer crashes without it:
    path: path.join(__dirname, 'build'),
    filename: 'bundle.js',
    publicPath: '/'
  },
  module: {
Dan Abramov's avatar
Dan Abramov committed
19
20
21
22
23
24
25
    preLoaders: [
      {
        test: /\.js$/,
        loader: 'eslint-loader',
        include: path.resolve(__dirname, 'src')
      }
    ],
Dan Abramov's avatar
Dan Abramov committed
26
    loaders: [
Dan Abramov's avatar
Dan Abramov committed
27
28
29
30
31
      {
        test: /\.js$/,
        include: path.resolve(__dirname, 'src'),
        loader: 'babel'
      },
Dan Abramov's avatar
Dan Abramov committed
32
33
34
35
36
37
      {
        test: /\.css$/,
        include: path.resolve(__dirname, 'src'),
        loader: 'style!css!postcss'
      },
      {
Dan Abramov's avatar
Dan Abramov committed
38
39
40
41
42
43
44
45
46
47
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/,
        loader: 'file',
      },
      {
        test: /\.(mp4|webm)$/,
        loader: 'url?limit=10000'
Dan Abramov's avatar
Dan Abramov committed
48
49
50
51
52
53
54
55
56
57
58
59
      }
    ]
  },
  postcss: function () {
    return [ autoprefixer ];
  },
  plugins: [
    // TODO: infer from package.json?
    new HtmlWebpackPlugin({ title: 'My React Project' }),
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' })
  ]
};