diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index a3db11f8ec7..e53be7aabb2 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -12,6 +12,7 @@ var autoprefixer = require('autoprefixer'); var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); +var CheckFilenamePlugin = require('check-filename-webpack-plugin'); var WatchMissingNodeModulesPlugin = require('../scripts/utils/WatchMissingNodeModulesPlugin'); var paths = require('./paths'); var env = require('./env'); @@ -66,7 +67,8 @@ module.exports = { }, resolve: { // These are the reasonable defaults supported by the Node ecosystem. - extensions: ['.js', '.json', ''], + // We also include .jsx extension in order to warn with CheckFilenamePlugin. + extensions: ['.jsx', '.js', '.json', ''], alias: { // This `alias` section can be safely removed after ejection. // We do this because `babel-runtime` may be inside `react-scripts`, @@ -179,6 +181,14 @@ module.exports = { // a plugin that prints an error when you attempt to do this. // See https://github.com/facebookincubator/create-react-app/issues/240 new CaseSensitivePathsPlugin(), + // Warn on using .jsx files, prefer using .js only. + // See https://github.com/facebookincubator/create-react-app/issues/290 + new CheckFilenamePlugin({ + regex: /\.jsx$/, + error: function(filename) { + return 'Module load aborted: .jsx extensions are not allowed, use .js extensions only. See create-react-app/issues/290 for more info.\n\tFor: ' + filename; + } + }), // If you require a missing module and then `npm install` it, you still have // to restart the development server for Webpack to discover it. This plugin // makes the discovery automatic so you don't have to restart. diff --git a/package.json b/package.json index bf3d853af2a..279e76e808c 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "babel-runtime": "6.11.6", "case-sensitive-paths-webpack-plugin": "1.1.2", "chalk": "1.1.3", + "check-filename-webpack-plugin": "^1.0.0", "connect-history-api-fallback": "1.2.0", "cross-spawn": "4.0.0", "css-loader": "0.23.1", diff --git a/template/README.md b/template/README.md index 441953eef69..d4f129e1381 100644 --- a/template/README.md +++ b/template/README.md @@ -81,6 +81,8 @@ You need to **put any JS and CSS files inside `src`**, or Webpack won’t see th You can, however, create more top-level directories. They will not be included in the production build so you can use them for things like documentation. +> NOTE: Only use `.js` file extensions for all JavaScript files inside `src`, including any React components. `.jsx` is explicitly not allowed, and an error will be thrown during compilation. See [create-react-app/issues/290](https://github.com/facebookincubator/create-react-app/issues/290) for more info. + ## Available Scripts In the project directory, you can run: