webpack.config.dev.js 2.02 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
var isInNodeModules = 'node_modules' ===
16
17
  path.basename(path.resolve(path.join(__dirname, '..', '..')));
var relative = isInNodeModules ? '../../..' : '..';
18

Dan Abramov's avatar
Dan Abramov committed
19
module.exports = {
20
21
  devtool: 'eval',
  entry: [
22
23
    'webpack-dev-server/client?http://localhost:3000',
    './src/index.js'
24
  ],
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
    pathinfo: true,
Dan Abramov's avatar
Dan Abramov committed
29
30
31
32
    filename: 'bundle.js',
    publicPath: '/'
  },
  module: {
Dan Abramov's avatar
Dan Abramov committed
33
34
35
    preLoaders: [
      {
        test: /\.js$/,
36
37
        loader: 'eslint',
        include: path.resolve(__dirname, relative, 'src'),
Dan Abramov's avatar
Dan Abramov committed
38
39
      }
    ],
Dan Abramov's avatar
Dan Abramov committed
40
    loaders: [
Dan Abramov's avatar
Dan Abramov committed
41
42
      {
        test: /\.js$/,
43
        include: path.resolve(__dirname, relative, 'src'),
44
        loader: 'babel',
45
        query: require('./babel.dev')
Dan Abramov's avatar
Dan Abramov committed
46
      },
Dan Abramov's avatar
Dan Abramov committed
47
48
      {
        test: /\.css$/,
49
        include: path.resolve(__dirname, relative, 'src'),
Dan Abramov's avatar
Dan Abramov committed
50
51
52
        loader: 'style!css!postcss'
      },
      {
Dan Abramov's avatar
Dan Abramov committed
53
54
55
56
57
58
59
60
61
62
        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
63
64
65
      }
    ]
  },
66
  eslint: {
67
68
    configFile: path.join(__dirname, 'eslint.js'),
    useEslintrc: false
69
70
71
  },
  postcss: function() {
    return [autoprefixer];
Dan Abramov's avatar
Dan Abramov committed
72
73
  },
  plugins: [
Max's avatar
Max committed
74
75
    new HtmlWebpackPlugin({
      inject: true,
Max's avatar
Max committed
76
      template: path.resolve(__dirname, relative, 'index.html'),
Max's avatar
Max committed
77
    }),
Dan Abramov's avatar
Dan Abramov committed
78
79
80
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' })
  ]
};