Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit 714971c

Browse files
committed
Move all the scripts to the scripts/ folder and use them from the scripts section of package.json
1 parent f0c3888 commit 714971c

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

global-cli/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ function run(root, appName, version, verbose) {
115115
process.cwd(),
116116
'node_modules',
117117
'create-react-app-scripts',
118+
'scripts',
118119
'init.js'
119120
);
120121
var init = require(scriptsPath);

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "create-react-app-scripts",
33
"version": "0.0.1",
44
"scripts": {
5-
"start": "cross-env NODE_ENV=development node devServer.js",
6-
"build": "rimraf build && cross-env NODE_ENV=production webpack --config webpack.config.prod.js"
5+
"start": "node scripts/start.js",
6+
"build": "node scripts/build.js"
77
},
88
"dependencies": {
99
"autoprefixer": "^6.3.7",
@@ -15,7 +15,6 @@
1515
"babel-preset-es2015": "^6.9.0",
1616
"babel-preset-es2016": "^6.11.3",
1717
"babel-preset-react": "^6.11.1",
18-
"cross-env": "^2.0.0",
1918
"css-loader": "^0.23.1",
2019
"eslint": "^2.13.1",
2120
"eslint-config-airbnb": "^9.0.1",
@@ -27,7 +26,6 @@
2726
"html-webpack-plugin": "^2.22.0",
2827
"json-loader": "^0.5.4",
2928
"postcss-loader": "^0.9.1",
30-
"rimraf": "^2.5.3",
3129
"style-loader": "^0.13.1",
3230
"url-loader": "^0.5.7",
3331
"webpack": "^1.13.1",

scripts/build.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
process.env.NODE_ENV = 'production';
2+
3+
var spawnSync = require('child_process').spawnSync;
4+
var webpack = require('webpack');
5+
var config = require('../webpack.config.prod');
6+
7+
spawnSync('rm', ['-rf', 'build']);
8+
webpack(config).run(function(err, stats) {
9+
if (err) {
10+
console.error(err);
11+
process.exit(1);
12+
}
13+
14+
console.log('Build successfully generated in the build/ folder');
15+
});

init.js renamed to scripts/init.js

File renamed without changes.

devServer.js renamed to scripts/start.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
process.env.NODE_ENV = 'development';
2+
13
var webpack = require('webpack');
24
var WebpackDevServer = require('webpack-dev-server');
3-
var config = require('./webpack.config.dev');
5+
var config = require('../webpack.config.dev');
46

57
new WebpackDevServer(webpack(config), {
68
publicPath: config.output.publicPath,

0 commit comments

Comments
 (0)