webpack.config.dev.js 1.84 KB
Newer Older
Christopher Chedeau's avatar
Christopher Chedeau committed
1
2
3
4
5
6
7
8
9
/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

Dan Abramov's avatar
Dan Abramov committed
10
11
12
13
14
var path = require('path');
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');

Dan Abramov's avatar
Dan Abramov committed
15
16
17
var isInNodeModules = 'node_modules' ===
  path.basename(path.resolve(path.join(__dirname, '..')));
var relative = isInNodeModules ? '../..' : '.';
18

Dan Abramov's avatar
Dan Abramov committed
19
module.exports = {
20
21
22
23
24
  devtool: 'eval',
  entry: [
    './src/index.js',
    'webpack-dev-server/client?http://localhost:3000'
  ],
Dan Abramov's avatar
Dan Abramov committed
25
26
  output: {
    // Next line is not used in dev but WebpackDevServer crashes without it:
27
    path: path.join(__dirname, relative, 'build'),
Dan Abramov's avatar
Dan Abramov committed
28
29
30
31
    filename: 'bundle.js',
    publicPath: '/'
  },
  module: {
Dan Abramov's avatar
Dan Abramov committed
32
33
34
35
    preLoaders: [
      {
        test: /\.js$/,
        loader: 'eslint-loader',
36
        include: path.resolve(__dirname, relative, 'src')
Dan Abramov's avatar
Dan Abramov committed
37
38
      }
    ],
Dan Abramov's avatar
Dan Abramov committed
39
    loaders: [
Dan Abramov's avatar
Dan Abramov committed
40
41
      {
        test: /\.js$/,
42
        include: path.resolve(__dirname, relative, 'src'),
Dan Abramov's avatar
Dan Abramov committed
43
44
        loader: 'babel'
      },
Dan Abramov's avatar
Dan Abramov committed
45
46
      {
        test: /\.css$/,
47
        include: path.resolve(__dirname, relative, 'src'),
Dan Abramov's avatar
Dan Abramov committed
48
49
50
        loader: 'style!css!postcss'
      },
      {
Dan Abramov's avatar
Dan Abramov committed
51
52
53
54
55
56
57
58
59
60
        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
61
62
63
64
65
66
67
68
69
70
71
72
      }
    ]
  },
  postcss: function () {
    return [ autoprefixer ];
  },
  plugins: [
    // TODO: infer from package.json?
    new HtmlWebpackPlugin({ title: 'My React Project' }),
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' })
  ]
};