Skip to content

Commit

Permalink
Move all the scripts to the scripts/ folder and use them from the scr…
Browse files Browse the repository at this point in the history
…ipts section of package.json
  • Loading branch information
vjeux committed Jul 18, 2016
1 parent f0c3888 commit 714971c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions global-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -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');
});
File renamed without changes.
4 changes: 3 additions & 1 deletion devServer.js → scripts/start.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 714971c

Please sign in to comment.