diff --git a/.gitignore b/.gitignore index 85e420fd9f..ef86dd7006 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /shells/browser/firefox/*.xpi /shells/browser/firefox/*.pem /shells/browser/shared/build +/shells/dev/dist build node_modules npm-debug.log diff --git a/package.json b/package.json index 7bf761f93b..479e760241 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ ] }, "scripts": { + "build:demo": "cd ./shells/dev && cross-env NODE_ENV=development cross-env TARGET=remote webpack --config webpack.config.js", "build:extension": "cross-env NODE_ENV=production yarn run build:extension:chrome && yarn run build:extension:firefox", "build:extension:dev": "cross-env NODE_ENV=development yarn run build:extension:chrome && yarn run build:extension:firefox", "build:extension:chrome": "cross-env NODE_ENV=production node ./shells/browser/chrome/build", @@ -38,7 +39,7 @@ "build:extension:firefox:dev": "cross-env NODE_ENV=development node ./shells/browser/firefox/build", "build:standalone": "cd packages/react-devtools-core && yarn run build", "deploy": "yarn run deploy:demo && yarn run deploy:chrome && yarn run deploy:firefox", - "deploy:demo": "cd shells/dev/ && now deploy && now alias react-devtools-experimental", + "deploy:demo": "yarn run build:demo && cd shells/dev/ && now deploy && now alias react-devtools-experimental", "deploy:chrome": "node ./shells/browser/chrome/deploy", "deploy:firefox": "node ./shells/browser/firefox/deploy", "linc": "lint-staged", @@ -47,8 +48,8 @@ "precommit": "lint-staged", "prettier": "prettier --write '**/*.{js,json,css}'", "prettier:ci": "prettier --check '**/*.{js,json,css}'", - "start": "cd ./shells/dev && cross-env NODE_ENV=development webpack-dev-server --open", - "start:prod": "cd ./shells/dev && cross-env NODE_ENV=production webpack-dev-server --open", + "start": "cd ./shells/dev && cross-env NODE_ENV=development cross-env TARGET=local webpack-dev-server --open", + "start:prod": "cd ./shells/dev && cross-env NODE_ENV=production cross-env TARGET=local webpack-dev-server --open", "test": "jest", "test-debug": "node --inspect-brk node_modules/.bin/jest --runInBand", "test:chrome": "node ./shells/browser/chrome/test", diff --git a/shells/dev/index.html b/shells/dev/index.html index 4f27aafc7a..f0252eee4d 100644 --- a/shells/dev/index.html +++ b/shells/dev/index.html @@ -61,7 +61,8 @@
- - + + + \ No newline at end of file diff --git a/shells/dev/now.json b/shells/dev/now.json index 1ba53f408c..7c0805c3b1 100644 --- a/shells/dev/now.json +++ b/shells/dev/now.json @@ -1,5 +1,5 @@ { "name": "react-devtools-experimental", "alias": ["react-devtools-experimental"], - "files": ["index.html", "build"] + "files": ["index.html", "dist"] } diff --git a/shells/dev/src/devtools.js b/shells/dev/src/devtools.js index 82030b02ed..d3de0e5d5e 100644 --- a/shells/dev/src/devtools.js +++ b/shells/dev/src/devtools.js @@ -38,7 +38,7 @@ mountButton.addEventListener('click', function() { } }); -inject('./app.js', () => { +inject('dist/app.js', () => { initDevTools({ connect(cb) { const bridge = new Bridge({ @@ -78,9 +78,11 @@ inject('./app.js', () => { // Initialize the backend only once the DevTools frontend Store has been initialized. // Otherwise the Store may miss important initial tree op codes. - inject('./backend.js', () => { - // Clear noisy webpack "WDS: ..." output. - console.clear(); + inject('dist/backend.js', () => { + if (__DEV__) { + // Clear noisy webpack "WDS: ..." output. + console.clear(); + } }); }); }, diff --git a/shells/dev/webpack.config.js b/shells/dev/webpack.config.js index dc2d0f7a24..6738e13117 100644 --- a/shells/dev/webpack.config.js +++ b/shells/dev/webpack.config.js @@ -8,20 +8,20 @@ if (!NODE_ENV) { process.exit(1); } +const TARGET = process.env.TARGET; +if (!TARGET) { + console.error('TARGET not set'); + process.exit(1); +} + const __DEV__ = NODE_ENV === 'development'; const GITHUB_URL = getGitHubURL(); const DEVTOOLS_VERSION = getVersionString(); -module.exports = { +const config = { mode: __DEV__ ? 'development' : 'production', devtool: false, - devServer: { - hot: true, - port: 8080, - clientLogLevel: 'warning', - stats: 'errors-only', - }, entry: { app: './app/index.js', backend: './src/backend.js', @@ -67,3 +67,20 @@ module.exports = { ], }, }; + +if (TARGET === 'local') { + config.devServer = { + hot: true, + port: 8080, + clientLogLevel: 'warning', + publicPath: '/dist/', + stats: 'errors-only', + }; +} else { + config.output = { + path: resolve(__dirname, 'dist'), + filename: '[name].js', + }; +} + +module.exports = config;