mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-03 17:16:02 +08:00
This enables us to ship them now, and find a way to resolve runtime path without webpack later. See https://github.com/facebookincubator/create-react-app/issues/255
104 lines
3.0 KiB
JavaScript
104 lines
3.0 KiB
JavaScript
/**
|
|
* 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.
|
|
*/
|
|
|
|
var path = require('path');
|
|
var autoprefixer = require('autoprefixer');
|
|
var webpack = require('webpack');
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
var paths = require('./paths');
|
|
|
|
module.exports = {
|
|
devtool: 'eval',
|
|
entry: [
|
|
require.resolve('webpack-dev-server/client'),
|
|
require.resolve('webpack/hot/dev-server'),
|
|
require.resolve('./polyfills'),
|
|
path.join(paths.appSrc, 'index')
|
|
],
|
|
output: {
|
|
// Next line is not used in dev but WebpackDevServer crashes without it:
|
|
path: paths.appBuild,
|
|
pathinfo: true,
|
|
filename: 'bundle.js',
|
|
publicPath: '/'
|
|
},
|
|
resolve: {
|
|
extensions: ['', '.js', '.json'],
|
|
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')
|
|
}
|
|
},
|
|
resolveLoader: {
|
|
root: paths.ownNodeModules,
|
|
moduleTemplates: ['*-loader']
|
|
},
|
|
module: {
|
|
preLoaders: [
|
|
{
|
|
test: /\.js$/,
|
|
loader: 'eslint',
|
|
include: paths.appSrc,
|
|
}
|
|
],
|
|
loaders: [
|
|
{
|
|
test: /\.js$/,
|
|
include: paths.appSrc,
|
|
loader: 'babel',
|
|
query: require('./babel.dev')
|
|
},
|
|
{
|
|
test: /\.css$/,
|
|
include: [paths.appSrc, paths.appNodeModules],
|
|
loader: 'style!css!postcss'
|
|
},
|
|
{
|
|
test: /\.json$/,
|
|
include: [paths.appSrc, paths.appNodeModules],
|
|
loader: 'json'
|
|
},
|
|
{
|
|
test: /\.(jpg|png|gif|eot|svg|ttf|woff|woff2)$/,
|
|
include: [paths.appSrc, paths.appNodeModules],
|
|
loader: 'file',
|
|
},
|
|
{
|
|
test: /\.(mp4|webm)$/,
|
|
include: [paths.appSrc, paths.appNodeModules],
|
|
loader: 'url?limit=10000'
|
|
}
|
|
]
|
|
},
|
|
eslint: {
|
|
configFile: path.join(__dirname, 'eslint.js'),
|
|
useEslintrc: false
|
|
},
|
|
postcss: function() {
|
|
return [autoprefixer];
|
|
},
|
|
plugins: [
|
|
new HtmlWebpackPlugin({
|
|
inject: true,
|
|
template: paths.appHtml,
|
|
favicon: paths.appFavicon,
|
|
}),
|
|
new webpack.DefinePlugin({ 'process.env.NODE_ENV': '"development"' }),
|
|
// Note: only CSS is currently hot reloaded
|
|
new webpack.HotModuleReplacementPlugin()
|
|
]
|
|
};
|