diff --git a/global-cli/index.js b/global-cli/index.js index f76d7adeaf0..61a09108564 100644 --- a/global-cli/index.js +++ b/global-cli/index.js @@ -115,6 +115,7 @@ function run(root, appName, version, verbose) { process.cwd(), 'node_modules', 'create-react-app-scripts', + 'scripts', 'init.js' ); var init = require(scriptsPath); diff --git a/package.json b/package.json index ba969cfa16c..0744588e1d5 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "create-react-app-scripts", "version": "0.0.1", "scripts": { - "start": "cross-env NODE_ENV=development node devServer.js", - "build": "rimraf build && cross-env NODE_ENV=production webpack --config webpack.config.prod.js" + "start": "node scripts/start.js", + "build": "node scripts/build.js" }, "dependencies": { "autoprefixer": "^6.3.7", @@ -15,7 +15,6 @@ "babel-preset-es2015": "^6.9.0", "babel-preset-es2016": "^6.11.3", "babel-preset-react": "^6.11.1", - "cross-env": "^2.0.0", "css-loader": "^0.23.1", "eslint": "^2.13.1", "eslint-config-airbnb": "^9.0.1", @@ -27,7 +26,6 @@ "html-webpack-plugin": "^2.22.0", "json-loader": "^0.5.4", "postcss-loader": "^0.9.1", - "rimraf": "^2.5.3", "style-loader": "^0.13.1", "url-loader": "^0.5.7", "webpack": "^1.13.1", diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 00000000000..70c2e7555f1 --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,15 @@ +process.env.NODE_ENV = 'production'; + +var spawnSync = require('child_process').spawnSync; +var webpack = require('webpack'); +var config = require('../webpack.config.prod'); + +spawnSync('rm', ['-rf', 'build']); +webpack(config).run(function(err, stats) { + if (err) { + console.error(err); + process.exit(1); + } + + console.log('Build successfully generated in the build/ folder'); +}); diff --git a/init.js b/scripts/init.js similarity index 100% rename from init.js rename to scripts/init.js diff --git a/devServer.js b/scripts/start.js similarity index 88% rename from devServer.js rename to scripts/start.js index 94423812027..55ac226a7e9 100644 --- a/devServer.js +++ b/scripts/start.js @@ -1,6 +1,8 @@ +process.env.NODE_ENV = 'development'; + var webpack = require('webpack'); var WebpackDevServer = require('webpack-dev-server'); -var config = require('./webpack.config.dev'); +var config = require('../webpack.config.dev'); new WebpackDevServer(webpack(config), { publicPath: config.output.publicPath,