webpack.config.dev.js 2.3 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
var path = require('path');
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
14
var paths = require('./paths');
15

Dan Abramov's avatar
Dan Abramov committed
16
module.exports = {
17
18
  devtool: 'eval',
  entry: [
19
    require.resolve('webpack-dev-server/client'),
20
    require.resolve('webpack/hot/dev-server'),
21
    require.resolve('./polyfills'),
22
    path.join(paths.appSrc, 'index')
23
  ],
Dan Abramov's avatar
Dan Abramov committed
24
25
  output: {
    // Next line is not used in dev but WebpackDevServer crashes without it:
26
    path: paths.appBuild,
Dan Abramov's avatar
Dan Abramov committed
27
    pathinfo: true,
Dan Abramov's avatar
Dan Abramov committed
28
29
30
    filename: 'bundle.js',
    publicPath: '/'
  },
31
  resolve: {
Dan Abramov's avatar
Dan Abramov committed
32
    extensions: ['', '.js', '.json'],
33
  },
34
  resolveLoader: {
35
    root: paths.ownNodeModules,
36
37
    moduleTemplates: ['*-loader']
  },
Dan Abramov's avatar
Dan Abramov committed
38
  module: {
Dan Abramov's avatar
Dan Abramov committed
39
40
41
    preLoaders: [
      {
        test: /\.js$/,
42
        loader: 'eslint',
43
        include: paths.appSrc,
Dan Abramov's avatar
Dan Abramov committed
44
45
      }
    ],
Dan Abramov's avatar
Dan Abramov committed
46
    loaders: [
Dan Abramov's avatar
Dan Abramov committed
47
48
      {
        test: /\.js$/,
49
        include: paths.appSrc,
50
        loader: 'babel',
51
        query: require('./babel.dev')
Dan Abramov's avatar
Dan Abramov committed
52
      },
Dan Abramov's avatar
Dan Abramov committed
53
54
      {
        test: /\.css$/,
55
        include: [paths.appSrc, paths.appNodeModules],
Dan Abramov's avatar
Dan Abramov committed
56
57
58
        loader: 'style!css!postcss'
      },
      {
Dan Abramov's avatar
Dan Abramov committed
59
        test: /\.json$/,
60
        include: [paths.appSrc, paths.appNodeModules],
Dan Abramov's avatar
Dan Abramov committed
61
62
63
64
        loader: 'json'
      },
      {
        test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/,
65
        include: [paths.appSrc, paths.appNodeModules],
Dan Abramov's avatar
Dan Abramov committed
66
67
68
69
        loader: 'file',
      },
      {
        test: /\.(mp4|webm)$/,
70
        include: [paths.appSrc, paths.appNodeModules],
Dan Abramov's avatar
Dan Abramov committed
71
        loader: 'url?limit=10000'
Dan Abramov's avatar
Dan Abramov committed
72
73
74
      }
    ]
  },
75
  eslint: {
76
77
    configFile: path.join(__dirname, 'eslint.js'),
    useEslintrc: false
78
79
80
  },
  postcss: function() {
    return [autoprefixer];
Dan Abramov's avatar
Dan Abramov committed
81
82
  },
  plugins: [
Max's avatar
Max committed
83
84
    new HtmlWebpackPlugin({
      inject: true,
85
86
      template: paths.appHtml,
      favicon: paths.appFavicon,
Max's avatar
Max committed
87
    }),
88
89
90
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' }),
    // Note: only CSS is currently hot reloaded
    new webpack.HotModuleReplacementPlugin()
Dan Abramov's avatar
Dan Abramov committed
91
92
  ]
};