Commit 6987b809 authored by Christopher Chedeau's avatar Christopher Chedeau
Browse files

Make the end to end install flow work :))

parent 714971cc
No related merge requests found
Showing with 24 additions and 14 deletions
+24 -14
......@@ -2,8 +2,8 @@
"name": "create-react-app-scripts",
"version": "0.0.1",
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js"
"start": "node scripts/start.js local",
"build": "node scripts/build.js local"
},
"dependencies": {
"autoprefixer": "^6.3.7",
......
......@@ -4,7 +4,9 @@ var spawnSync = require('child_process').spawnSync;
var webpack = require('webpack');
var config = require('../webpack.config.prod');
spawnSync('rm', ['-rf', 'build']);
var relative = process.argv[2] === 'local' ? '.' : '../..';
spawnSync('rm', ['-rf', relative + '/build']);
webpack(config).run(function(err, stats) {
if (err) {
console.error(err);
......
var fs = require('fs');
module.exports = function(hostPath, appName) {
var selfPath = hostPath + '/node_modules/create-react-app-scripts';
......@@ -11,14 +13,16 @@ module.exports = function(hostPath, appName) {
// Setup the script rules
hostPackage.scripts = {};
['start', 'build', 'publish-gh-pages'].forEach(function(command) {
hostPackage.scripts[command] = 'node node_modules/create-react-app-scripts/' + command + '.js';
['start', 'build'].forEach(function(command) {
hostPackage.scripts[command] = 'node node_modules/create-react-app-scripts/scripts/' + command + '.js';
});
fs.writeFileSync(hostPath + '/package.json', JSON.stringify(hostPackage, null, 2));
// TODO: run npm install in hostPath, (not needed for npm 3 if we accept some hackery)
// Move the src folder
fs.renameSync(selfPackage + '/src', hostPackage + '/src');
fs.renameSync(selfPath + '/src', hostPath + '/src');
console.log('Creating the app', appName, 'at', hostPath);
};
......@@ -3,6 +3,8 @@ var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var relative = process.argv[2] === 'local' ? '.' : '../..';
module.exports = {
devtool: 'eval',
entry: [
......@@ -11,7 +13,7 @@ module.exports = {
],
output: {
// Next line is not used in dev but WebpackDevServer crashes without it:
path: path.join(__dirname, 'build'),
path: path.join(__dirname, relative, 'build'),
filename: 'bundle.js',
publicPath: '/'
},
......@@ -20,18 +22,18 @@ module.exports = {
{
test: /\.js$/,
loader: 'eslint-loader',
include: path.resolve(__dirname, 'src')
include: path.resolve(__dirname, relative, 'src')
}
],
loaders: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
include: path.resolve(__dirname, relative, 'src'),
loader: 'babel'
},
{
test: /\.css$/,
include: path.resolve(__dirname, 'src'),
include: path.resolve(__dirname, relative, 'src'),
loader: 'style!css!postcss'
},
{
......
......@@ -3,11 +3,13 @@ var autoprefixer = require('autoprefixer');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var relative = process.argv[2] === 'local' ? '.' : '../..';
module.exports = {
devtool: 'source-map',
entry: './src/index.js',
output: {
path: path.join(__dirname, 'build'),
path: path.resolve(__dirname, relative, 'build'),
filename: '[name].[hash].js',
// TODO: this wouldn't work for e.g. GH Pages.
// Good news: we can infer it from package.json :-)
......@@ -18,18 +20,18 @@ module.exports = {
{
test: /\.js$/,
loader: 'eslint-loader',
include: path.resolve(__dirname, 'src')
include: path.resolve(__dirname, relative, 'src')
}
],
loaders: [
{
test: /\.js$/,
include: path.resolve(__dirname, 'src'),
include: path.resolve(__dirname, relative, 'src'),
loader: 'babel'
},
{
test: /\.css$/,
include: path.resolve(__dirname, 'src'),
include: path.resolve(__dirname, relative, 'src'),
loader: 'style!css!postcss'
},
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment