Move all the scripts to the scripts/ folder and use them from the scripts section of package.json

This commit is contained in:
Christopher Chedeau
2016-07-15 14:43:06 -07:00
parent f0c3888779
commit 714971cccc
5 changed files with 21 additions and 5 deletions

View File

@@ -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);

View File

@@ -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",

15
scripts/build.js Normal file
View File

@@ -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');
});

View File

@@ -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,