webpack.config.dev.js 3.24 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 CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
15
var paths = require('./paths');
16

Dan Abramov's avatar
Dan Abramov committed
17
module.exports = {
18
19
  devtool: 'eval',
  entry: [
20
    require.resolve('webpack-dev-server/client') + '?/',
21
    require.resolve('webpack/hot/dev-server'),
22
    require.resolve('./polyfills'),
23
    path.join(paths.appSrc, 'index')
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: paths.appBuild,
Dan Abramov's avatar
Dan Abramov committed
28
    pathinfo: true,
29
    filename: 'static/js/bundle.js',
Dan Abramov's avatar
Dan Abramov committed
30
31
    publicPath: '/'
  },
32
  resolve: {
Dan Abramov's avatar
Dan Abramov committed
33
    extensions: ['', '.js', '.json'],
34
35
36
37
38
39
40
41
42
43
44
    alias: {
      // This `alias` section can be safely removed after ejection.
      // We do this because `babel-runtime` may be inside `react-scripts`,
      // so when `babel-plugin-transform-runtime` imports it, it will not be
      // available to the app directly. This is a temporary solution that lets
      // us ship support for generators. However it is far from ideal, and
      // if we don't have a good solution, we should just make `babel-runtime`
      // a dependency in generated projects.
      // See https://github.com/facebookincubator/create-react-app/issues/255
      'babel-runtime/regenerator': require.resolve('babel-runtime/regenerator')
    }
45
  },
46
  resolveLoader: {
47
    root: paths.ownNodeModules,
48
49
    moduleTemplates: ['*-loader']
  },
Dan Abramov's avatar
Dan Abramov committed
50
  module: {
Dan Abramov's avatar
Dan Abramov committed
51
52
53
    preLoaders: [
      {
        test: /\.js$/,
54
        loader: 'eslint',
55
        include: paths.appSrc,
Dan Abramov's avatar
Dan Abramov committed
56
57
      }
    ],
Dan Abramov's avatar
Dan Abramov committed
58
    loaders: [
Dan Abramov's avatar
Dan Abramov committed
59
60
      {
        test: /\.js$/,
61
        include: paths.appSrc,
62
        loader: 'babel',
63
        query: require('./babel.dev')
Dan Abramov's avatar
Dan Abramov committed
64
      },
Dan Abramov's avatar
Dan Abramov committed
65
66
      {
        test: /\.css$/,
67
        include: [paths.appSrc, paths.appNodeModules],
Dan Abramov's avatar
Dan Abramov committed
68
69
70
        loader: 'style!css!postcss'
      },
      {
Dan Abramov's avatar
Dan Abramov committed
71
        test: /\.json$/,
72
        include: [paths.appSrc, paths.appNodeModules],
Dan Abramov's avatar
Dan Abramov committed
73
74
75
76
        loader: 'json'
      },
      {
        test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/,
77
        include: [paths.appSrc, paths.appNodeModules],
Dan Abramov's avatar
Dan Abramov committed
78
        loader: 'file',
79
80
81
        query: {
          name: 'static/media/[name].[ext]'
        }
Dan Abramov's avatar
Dan Abramov committed
82
83
84
      },
      {
        test: /\.(mp4|webm)$/,
85
        include: [paths.appSrc, paths.appNodeModules],
86
87
88
89
90
        loader: 'url',
        query: {
          limit: 10000,
          name: 'static/media/[name].[ext]'
        }
Dan Abramov's avatar
Dan Abramov committed
91
92
93
      }
    ]
  },
94
  eslint: {
95
96
    configFile: path.join(__dirname, 'eslint.js'),
    useEslintrc: false
97
98
99
  },
  postcss: function() {
    return [autoprefixer];
Dan Abramov's avatar
Dan Abramov committed
100
101
  },
  plugins: [
Max's avatar
Max committed
102
103
    new HtmlWebpackPlugin({
      inject: true,
104
105
      template: paths.appHtml,
      favicon: paths.appFavicon,
Max's avatar
Max committed
106
    }),
107
108
    new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' }),
    // Note: only CSS is currently hot reloaded
109
110
    new webpack.HotModuleReplacementPlugin(),
    new CaseSensitivePathsPlugin()
Dan Abramov's avatar
Dan Abramov committed
111
112
  ]
};