This commit is contained in:
MICHAEL JACKSON
2017-11-25 21:19:55 -08:00
parent 758b420297
commit 51f3bca3fb
13 changed files with 476 additions and 448 deletions

View File

@ -1,25 +1,23 @@
'use strict';
var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
var getClientEnvironment = require('./env');
var paths = require('./paths');
"use strict"
var autoprefixer = require("autoprefixer")
var webpack = require("webpack")
var HtmlWebpackPlugin = require("html-webpack-plugin")
var CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin")
var InterpolateHtmlPlugin = require("react-dev-utils/InterpolateHtmlPlugin")
var WatchMissingNodeModulesPlugin = require("react-dev-utils/WatchMissingNodeModulesPlugin")
var getClientEnvironment = require("./env")
var paths = require("./paths")
// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
var publicPath = '/';
var publicPath = "/"
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
var publicUrl = '';
var publicUrl = ""
// Get environment variables to inject into our app.
var env = getClientEnvironment(publicUrl);
var env = getClientEnvironment(publicUrl)
// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
@ -27,7 +25,7 @@ var env = getClientEnvironment(publicUrl);
module.exports = {
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
devtool: 'cheap-module-source-map',
devtool: "cheap-module-source-map",
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
@ -42,9 +40,9 @@ module.exports = {
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
require.resolve('react-dev-utils/webpackHotDevClient'),
require.resolve("react-dev-utils/webpackHotDevClient"),
// We ship a few polyfills by default:
require.resolve('./polyfills'),
require.resolve("./polyfills"),
// Finally, this is your app's code:
paths.appIndexJs
// We include the app code last so that if there is a runtime error during
@ -59,7 +57,7 @@ module.exports = {
// This does not produce a real file. It's just the virtual path that is
// served by WebpackDevServer in development. This is the JS bundle
// containing code from all our entry points, and the Webpack runtime.
filename: '_static/js/bundle.js',
filename: "_static/js/bundle.js",
// This is the URL that app is served from. We use "/" in development.
publicPath: publicPath
},
@ -74,22 +72,22 @@ module.exports = {
// We also include JSX as a common component filename extension to support
// some tools, although we do not recommend using it, see:
// https://github.com/facebookincubator/create-react-app/issues/290
extensions: ['.js', '.json', '.jsx', ''],
extensions: [".js", ".json", ".jsx", ""],
alias: {
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web'
"react-native": "react-native-web"
}
},
module: {
// First, run the linter.
// It's important to do this before Babel processes the JS.
preLoaders: [
{
test: /\.(js|jsx)$/,
loader: 'eslint',
include: paths.appSrc,
loader: "eslint",
include: paths.appSrc
}
],
loaders: [
@ -116,19 +114,18 @@ module.exports = {
/\.svg$/,
/\.md$/
],
loader: 'url',
loader: "url",
query: {
limit: 10000,
name: '_static/media/[name].[hash:8].[ext]'
name: "_static/media/[name].[hash:8].[ext]"
}
},
// Process JS with Babel.
{
test: /\.(js|jsx)$/,
include: paths.appSrc,
loader: 'babel',
loader: "babel",
query: {
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
@ -142,44 +139,44 @@ module.exports = {
// in development "style" loader enables hot editing of CSS.
{
test: /\.css$/,
loader: 'style!css?importLoaders=1!postcss'
loader: "style!css?importLoaders=1!postcss"
},
// JSON is not enabled by default in Webpack but both Node and Browserify
// allow it implicitly so we also enable it.
{
test: /\.json$/,
loader: 'json'
loader: "json"
},
// "file" loader for svg
{
test: /\.svg$/,
loader: 'file',
loader: "file",
query: {
name: '_static/media/[name].[hash:8].[ext]'
name: "_static/media/[name].[hash:8].[ext]"
}
},
// HTML loader for Markdown files.
{
test: /\.md$/,
loader: 'html!markdown'
loader: "html!markdown"
}
// ** STOP ** Are you adding a new loader?
// Remember to add the new extension(s) to the "url" loader exclusion list.
]
},
// We use PostCSS for autoprefixing only.
postcss: function() {
return [
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 9" // React doesn't support IE8 anyway
]
}),
];
})
]
},
plugins: [
// Makes some environment variables available in index.html.
@ -190,7 +187,7 @@ module.exports = {
// Generates an `index.html` file with the <script> injected.
new HtmlWebpackPlugin({
inject: true,
template: paths.appHtml,
template: paths.appHtml
}),
// Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
@ -210,8 +207,8 @@ module.exports = {
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
fs: 'empty',
net: 'empty',
tls: 'empty'
fs: "empty",
net: "empty",
tls: "empty"
}
};
}