Use global React, ReactDOM, and ReactRouterDOM from unpkg

This commit is contained in:
Michael Jackson 2018-07-10 07:49:35 +10:00
parent aa118eecef
commit 43379bb73d
5 changed files with 28 additions and 4 deletions

View File

@ -1,3 +1,8 @@
{
"presets": ["env", "stage-2", "react"]
"presets": ["env", "stage-2", "react"],
"env": {
"production": {
"plugins": ["transform-react-remove-prop-types"]
}
}
}

View File

@ -45,6 +45,7 @@
"devDependencies": {
"babel-eslint": "^8.0.3",
"babel-loader": "^7.1.2",
"babel-plugin-transform-react-remove-prop-types": "^0.4.13",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
@ -68,6 +69,9 @@
"node": "8"
},
"jest": {
"testPathIgnorePatterns": ["/node_modules/", "__tests__/utils"]
"testPathIgnorePatterns": [
"/node_modules/",
"__tests__/utils"
]
}
}

View File

@ -26,6 +26,11 @@ function MainPage({ title, description, scripts, styles, content }) {
x(
"window.fetch || document.write('\\x3Cscript src=\"/_polyfills/fetch.min.js\">\\x3C/script>')"
),
e("script", { src: "/react@16.4.1/umd/react.production.min.js" }),
e("script", { src: "/react-dom@16.4.1/umd/react-dom.production.min.js" }),
e("script", {
src: "/react-router-dom@4.3.1/umd/react-router-dom.min.js"
}),
styles.map(s => e("link", { key: s, rel: "stylesheet", href: s }))
),
e(

View File

@ -6,6 +6,12 @@ module.exports = {
main: path.resolve(__dirname, "client/main.js")
},
externals: {
react: "React",
"react-dom": "ReactDOM",
"react-router-dom": "ReactRouterDOM"
},
output: {
filename: "[name]-[hash:8].js",
path: path.resolve(__dirname, "public/_assets"),
@ -14,10 +20,10 @@ module.exports = {
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: ["babel-loader"] },
{ test: /\.js$/, exclude: /node_modules/, use: "babel-loader" },
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
{ test: /\.md$/, use: ["html-loader", "markdown-loader"] },
{ test: /\.png$/, use: ["file-loader"] }
{ test: /\.png$/, use: "file-loader" }
]
},

View File

@ -907,6 +907,10 @@ babel-plugin-transform-react-jsx@^6.24.1:
babel-plugin-syntax-jsx "^6.8.0"
babel-runtime "^6.22.0"
babel-plugin-transform-react-remove-prop-types@^0.4.13:
version "0.4.13"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.13.tgz#331cfc05099a808238311d78319c27460d481189"
babel-plugin-transform-regenerator@^6.22.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f"