From 6908555ffbecfa2b0baa37b7d288a0cef3b886a4 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:20:01 -0500 Subject: [PATCH 01/16] Add missing peer dependencies --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 5ecf63c..12d8315 100644 --- a/package.json +++ b/package.json @@ -80,6 +80,7 @@ "css-loader": "^0.22.0", "eslint": "^1.9.0", "eslint-plugin-react": "^3.8.0", + "file-loader": "^0.8.4", "gh-pages": "^0.5.0", "grunt": "^0.4.5", "grunt-concurrent": "^2.0.4", @@ -91,6 +92,7 @@ "grunt-karma": "^0.12.1", "grunt-open": "^0.2.3", "grunt-webpack": "^1.0.11", + "jasmine-core": "^2.3.4", "jest-cli": "^0.7.1", "jshint": "^2.8.0", "jshint-loader": "^0.8.3", @@ -102,6 +104,8 @@ "karma-script-launcher": "^0.1.0", "karma-webpack": "^1.7.0", "load-grunt-tasks": "^3.3.0", + "node-sass": "^3.4.1", + "phantomjs": "^1.9.18", "react-hot-loader": "^1.3.0", "sass-loader": "^3.1.1", "style-loader": "^0.13.0", From 3f79ea33ad7fceaf48969026c9d86b298cf2edd7 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:20:45 -0500 Subject: [PATCH 02/16] Convert karma grunt task to npm script --- Gruntfile.js | 7 ------- package.json | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9b5ab45..d73cb42 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -69,12 +69,6 @@ module.exports = function (grunt) { } }, - 'karma': { - unit: { - configFile: 'karma.conf.js' - } - }, - 'copy': { dist: { files: [ @@ -144,7 +138,6 @@ module.exports = function (grunt) { ]); }); - grunt.registerTask('test', ['karma']); grunt.registerTask('build', ['clean', 'copy', 'webpack']); grunt.registerTask('default', []); }; diff --git a/package.json b/package.json index 12d8315..63b5d55 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "scripts": { "build": "grunt build", "deploy": "gh-pages -d dist", + "karma": "`npm bin`/karma start", "travis": "npm run build && npm run react-native:ios && npm run react-native:android && npm test", "react-native:ios": "react-native bundle --root src --platform ios --minify", "react-native:android": "react-native bundle --root src --platform android --minify", @@ -32,7 +33,7 @@ "serve-web": "grunt serve-web", "serve-web:dist": "grunt serve-web:dist", "start": "node_modules/react-native/packager/packager.sh", - "test": "jest" + "test": "`npm bin`/jest" }, "window": { "toolbar": true, @@ -89,7 +90,6 @@ "grunt-contrib-copy": "^0.8.2", "grunt-contrib-watch": "^0.6.1", "grunt-exec": "^0.4.6", - "grunt-karma": "^0.12.1", "grunt-open": "^0.2.3", "grunt-webpack": "^1.0.11", "jasmine-core": "^2.3.4", From 15fc27b70a856c8186898ffabb60d3fdaeae7bb4 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:21:48 -0500 Subject: [PATCH 03/16] Improved configuration sharing in webpack profiles --- Gruntfile.js | 2 +- karma.conf.js | 24 ++---------------------- webpack.config.js | 28 +++++++++++++--------------- webpack.dist.config.js | 38 +++++++------------------------------- webpack.hot.config.js | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 69 deletions(-) create mode 100644 webpack.hot.config.js diff --git a/Gruntfile.js b/Gruntfile.js index d73cb42..6c99dc2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,7 +7,7 @@ var mountFolder = function (dir) { }; var webpackDistConfig = require('./webpack.dist.config.js'); -var webpackDevConfig = require('./webpack.config.js'); +var webpackDevConfig = require('./webpack.hot.config.js'); module.exports = function (grunt) { // Let *load-grunt-tasks* require everything diff --git a/karma.conf.js b/karma.conf.js index ae1d042..f868a67 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,6 @@ 'use strict'; -var path = require('path'); +var webpackConfig = require('./webpack.config.js'); module.exports = function (config) { config.set({ @@ -19,27 +19,7 @@ module.exports = function (config) { }, webpack: { cache: true, - module: { - loaders: [{ - test: /\.gif/, - loader: 'url-loader?limit=10000&mimetype=image/gif' - }, { - test: /\.jpg/, - loader: 'url-loader?limit=10000&mimetype=image/jpg' - }, { - test: /\.png/, - loader: 'url-loader?limit=10000&mimetype=image/png' - }, { - test: /\.js$/, - loader: 'babel-loader' - }, { - test: /\.sass/, - loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded' - }, { - test: /\.css$/, - loader: 'style-loader!css-loader' - }] - } + module: webpackConfig.module }, webpackServer: { stats: { diff --git a/webpack.config.js b/webpack.config.js index 8a20ea3..af3c51b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,36 +1,34 @@ /* - * Webpack development server configuration + * Webpack base configuration */ 'use strict'; -var webpack = require('webpack'); - module.exports = { + devtool: 'source-map', + + entry: [ + './src/index.js' + ], + output: { filename: 'main.js', + path: 'dist/assets/', publicPath: '/assets/' }, - cache: true, - debug: true, - devtool: false, - entry: [ - 'webpack/hot/only-dev-server', - './src/index.js' - ], + stats: { colors: true, reasons: true }, - plugins: [ - new webpack.HotModuleReplacementPlugin(), - new webpack.NoErrorsPlugin() - ], + + plugins: [], + module: { loaders: [{ test: /\.js$/, exclude: /node_modules/, - loader: 'react-hot!babel-loader' + loader: 'babel-loader' }, { test: /\.sass/, loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax' diff --git a/webpack.dist.config.js b/webpack.dist.config.js index a65c7fe..4e02671 100644 --- a/webpack.dist.config.js +++ b/webpack.dist.config.js @@ -6,41 +6,17 @@ 'use strict'; +require('babel/register'); var webpack = require('webpack'); +var baseConfig = require('./webpack.config.js'); -module.exports = { - output: { - publicPath: '/assets/', - path: 'dist/assets/', - filename: 'main.js' - }, - debug: false, +module.exports = Object.assign({}, baseConfig, { devtool: false, - entry: './src/index.js', - stats: { - colors: true, - reasons: false - }, - plugins: [ + + plugins: baseConfig.plugins.concat([ new webpack.optimize.DedupePlugin(), new webpack.optimize.UglifyJsPlugin(), new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.AggressiveMergingPlugin() - ], - module: { - loaders: [{ - test: /\.js$/, - exclude: /node_modules/, - loader: 'babel-loader' - }, { - test: /\.css$/, - loader: 'style-loader!css-loader' - }, { - test: /\.sass/, - loader: 'style-loader!css-loader!sass-loader?outputStyle=expanded&indentedSyntax' - }, { - test: /\.(png|jpg)$/, - loader: 'url-loader?limit=8192' - }] - } -}; + ]) +}); diff --git a/webpack.hot.config.js b/webpack.hot.config.js new file mode 100644 index 0000000..cbf4e8a --- /dev/null +++ b/webpack.hot.config.js @@ -0,0 +1,24 @@ +/* + * Webpack development server configuration + */ + +'use strict'; + +require('babel/register'); +var webpack = require('webpack'); +var baseConfig = require('./webpack.config.js'); + +module.exports = Object.assign({}, baseConfig, { + debug: true, + + entry: [ + 'webpack/hot/only-dev-server' + ].concat(baseConfig.entry), + + plugins: baseConfig.plugins.concat([ + new webpack.HotModuleReplacementPlugin(), + new webpack.NoErrorsPlugin() + ]) +}); + +module.exports.module.loaders[0].loader = 'react-hot!babel-loader'; From 8a319bb63b7adbb25356fea83a9812368e1b776d Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:22:33 -0500 Subject: [PATCH 04/16] Remove webpack publicPath configuration --- Gruntfile.js | 1 - webpack.config.js | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6c99dc2..0d505d1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -31,7 +31,6 @@ module.exports = function (grunt) { hot: true, port: 8000, webpack: webpackDevConfig, - publicPath: '/assets/', contentBase: './<%= pkg.src %>/' }, diff --git a/webpack.config.js b/webpack.config.js index af3c51b..3ba7a4e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,9 +12,8 @@ module.exports = { ], output: { - filename: 'main.js', - path: 'dist/assets/', - publicPath: '/assets/' + filename: 'assets/main.js', + path: 'dist/' }, stats: { From c5929d0b09bb82853be9e7c4d4ce7af303f0e5ba Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:23:00 -0500 Subject: [PATCH 05/16] Serve content from dist/ --- Gruntfile.js | 34 ++++------------------------------ README.md | 2 +- index.nw.html | 2 +- package.json | 1 - 4 files changed, 6 insertions(+), 33 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0d505d1..9a6658f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,11 +1,5 @@ 'use strict'; -var serveStatic = require('serve-static'); - -var mountFolder = function (dir) { - return serveStatic(require('path').resolve(dir)); -}; - var webpackDistConfig = require('./webpack.dist.config.js'); var webpackDevConfig = require('./webpack.hot.config.js'); @@ -31,7 +25,7 @@ module.exports = function (grunt) { hot: true, port: 8000, webpack: webpackDevConfig, - contentBase: './<%= pkg.src %>/' + contentBase: './dist/' }, start: { @@ -39,30 +33,10 @@ module.exports = function (grunt) { } }, - 'connect': { - options: { - port: 8000 - }, - - dist: { - options: { - keepalive: true, - middleware: function () { - return [ - mountFolder(pkgConfig.dist) - ]; - } - } - } - }, - 'open': { options: { delay: 500 }, - dev: { - path: 'http://localhost:<%= connect.options.port %>/webpack-dev-server/index.web.html' - }, dist: { path: 'http://localhost:<%= connect.options.port %>/index.html' } @@ -107,7 +81,7 @@ module.exports = function (grunt) { }, 'exec': { - launch_nw: '/Applications/nwjs.app/Contents/MacOS/nwjs .' + launch_nw: '/Applications/nwjs.app/Contents/MacOS/nwjs dist' }, 'concurrent': { @@ -122,11 +96,11 @@ module.exports = function (grunt) { grunt.registerTask('serve-web', function (target) { if (target === 'dist') { - return grunt.task.run(['build', 'open:dist', 'connect:dist']); + return grunt.task.run(['build', 'open:dist']); } grunt.task.run([ - 'open:dev', + 'open:dist', 'webpack-dev-server' ]); }); diff --git a/README.md b/README.md index 651b5a5..6ca9eaa 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ There isn't any addtional requirements since you already installed the deps with ### Quick start - `npm run build` to build the project (at least the first time) -- `npm run serve-web` to preview in the browser at http://localhost:8000/index.web.html or http://localhost:8000/webpack-dev-server/index.web.html with webpack-dev-server and hot reload enabled +- `npm run serve-web` to preview in the browser at http://localhost:8000/index.web.html with webpack-dev-server and hot reload enabled Congratulations! You've just successfully run the project as a Website App. diff --git a/index.nw.html b/index.nw.html index 4ec0975..b0c51fd 100644 --- a/index.nw.html +++ b/index.nw.html @@ -7,7 +7,7 @@
- + diff --git a/package.json b/package.json index 63b5d55..2f0bebb 100644 --- a/package.json +++ b/package.json @@ -86,7 +86,6 @@ "grunt": "^0.4.5", "grunt-concurrent": "^2.0.4", "grunt-contrib-clean": "^0.6.0", - "grunt-contrib-connect": "^0.11.2", "grunt-contrib-copy": "^0.8.2", "grunt-contrib-watch": "^0.6.1", "grunt-exec": "^0.4.6", From 42326a48567ed62769c150f28d5e4fd9f4c19fc9 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:23:12 -0500 Subject: [PATCH 06/16] Use a single common index.html file --- Gruntfile.js | 2 +- README.md | 2 +- index.web.html => index.html | 2 +- index.nw.html | 13 ------------- package.json | 2 +- 5 files changed, 4 insertions(+), 17 deletions(-) rename index.web.html => index.html (95%) delete mode 100644 index.nw.html diff --git a/Gruntfile.js b/Gruntfile.js index 9a6658f..424ab47 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -38,7 +38,7 @@ module.exports = function (grunt) { delay: 500 }, dist: { - path: 'http://localhost:<%= connect.options.port %>/index.html' + path: 'http://localhost:8000/' } }, diff --git a/README.md b/README.md index 6ca9eaa..06caff2 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ There isn't any addtional requirements since you already installed the deps with ### Quick start - `npm run build` to build the project (at least the first time) -- `npm run serve-web` to preview in the browser at http://localhost:8000/index.web.html with webpack-dev-server and hot reload enabled +- `npm run serve-web` to preview in the browser at http://localhost:8000/ with webpack-dev-server and hot reload enabled Congratulations! You've just successfully run the project as a Website App. diff --git a/index.web.html b/index.html similarity index 95% rename from index.web.html rename to index.html index 84cbeee..cf872da 100644 --- a/index.web.html +++ b/index.html @@ -2,7 +2,7 @@ - Calculator Web App + Calculator App diff --git a/index.nw.html b/index.nw.html deleted file mode 100644 index b0c51fd..0000000 --- a/index.nw.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - Calculator Desktop App - - -
- - - - - diff --git a/package.json b/package.json index 2f0bebb..6b4da08 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dist": "./dist", "mainInput": "main", "mainOutput": "main", - "main": "index.nw.html", + "main": "index.html", "scripts": { "build": "grunt build", "deploy": "gh-pages -d dist", From 851e5f5b3f88a7c08d7bfaf6821b46ef6aee3e08 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:23:23 -0500 Subject: [PATCH 07/16] Copy package.json for nwjs during build --- package.json | 10 ---------- src/index.js | 2 ++ src/package.web.json | 11 +++++++++++ 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 src/package.web.json diff --git a/package.json b/package.json index 6b4da08..3ff0141 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,6 @@ "src": "./", "test": "./test", "dist": "./dist", - "mainInput": "main", - "mainOutput": "main", - "main": "index.html", "scripts": { "build": "grunt build", "deploy": "gh-pages -d dist", @@ -35,13 +32,6 @@ "start": "node_modules/react-native/packager/packager.sh", "test": "`npm bin`/jest" }, - "window": { - "toolbar": true, - "min_width": 300, - "min_height": 475, - "max_width": 800, - "max_height": 600 - }, "jest": { "scriptPreprocessor": "/node_modules/babel-jest", "testFileExtensions": [ diff --git a/src/index.js b/src/index.js index 05ca008..d3e4f03 100644 --- a/src/index.js +++ b/src/index.js @@ -5,6 +5,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Router, Route } from 'react-router'; +require('file?name=package.json!./package.web.json'); + // CSS require('normalize.css'); require('./styles/main.css'); diff --git a/src/package.web.json b/src/package.web.json new file mode 100644 index 0000000..21ea46e --- /dev/null +++ b/src/package.web.json @@ -0,0 +1,11 @@ +{ + "name": "react-native-nw-react-calculator-nwjs", + "main": "index.html", + "window": { + "toolbar": true, + "min_width": 300, + "min_height": 475, + "max_width": 800, + "max_height": 600 + } +} From 14dd2ffe0a9635e266d44423c3b96047714fb1fc Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:23:53 -0500 Subject: [PATCH 08/16] Copy favicon.ico during build --- src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.js b/src/index.js index d3e4f03..c116947 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ import ReactDOM from 'react-dom'; import { Router, Route } from 'react-router'; require('file?name=package.json!./package.web.json'); +require('file?name=favicon.ico!../favicon.ico'); // CSS require('normalize.css'); From 83c1db164849d8c25837b7066ff45ee7a0de1906 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:24:03 -0500 Subject: [PATCH 09/16] Generate index.html during build --- index.html | 15 ++++++++++++--- package.json | 1 + webpack.config.js | 9 ++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index cf872da..609c401 100644 --- a/index.html +++ b/index.html @@ -1,8 +1,14 @@ - + - Calculator App + {%=o.htmlWebpackPlugin.options.title || 'Webpack App'%} + {% if (o.htmlWebpackPlugin.files.favicon) { %} + + {% } %} + {% for (var css in o.htmlWebpackPlugin.files.css) { %} + + {% } %} @@ -16,6 +22,9 @@ - + + {% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %} + + {% } %} diff --git a/package.json b/package.json index 3ff0141..1aab441 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "grunt-exec": "^0.4.6", "grunt-open": "^0.2.3", "grunt-webpack": "^1.0.11", + "html-webpack-plugin": "^1.6.2", "jasmine-core": "^2.3.4", "jest-cli": "^0.7.1", "jshint": "^2.8.0", diff --git a/webpack.config.js b/webpack.config.js index 3ba7a4e..0f587db 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,6 +4,8 @@ 'use strict'; +var HtmlWebpackPlugin = require('html-webpack-plugin'); + module.exports = { devtool: 'source-map', @@ -21,7 +23,12 @@ module.exports = { reasons: true }, - plugins: [], + plugins: [ + new HtmlWebpackPlugin({ + title: 'Calculator App', + template: './index.html' + }) + ], module: { loaders: [{ From d67586ad8c21dcb2bcca7b0f75aba30cb1deb071 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:24:35 -0500 Subject: [PATCH 10/16] Remove unnecessary grunt copy task --- Gruntfile.js | 19 +------------------ package.json | 1 - 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 424ab47..ae333a8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -42,23 +42,6 @@ module.exports = function (grunt) { } }, - 'copy': { - dist: { - files: [ - { - flatten: true, - src: ['<%= pkg.src %>/index.web.html'], - dest: '<%= pkg.dist %>/index.html' - }, - { - flatten: true, - src: ['<%= pkg.src %>/favicon.ico'], - dest: '<%= pkg.dist %>/favicon.ico' - } - ] - } - }, - 'clean': { dist: { files: [{ @@ -111,6 +94,6 @@ module.exports = function (grunt) { ]); }); - grunt.registerTask('build', ['clean', 'copy', 'webpack']); + grunt.registerTask('build', ['clean', 'webpack']); grunt.registerTask('default', []); }; diff --git a/package.json b/package.json index 1aab441..af78fdc 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "grunt": "^0.4.5", "grunt-concurrent": "^2.0.4", "grunt-contrib-clean": "^0.6.0", - "grunt-contrib-copy": "^0.8.2", "grunt-contrib-watch": "^0.6.1", "grunt-exec": "^0.4.6", "grunt-open": "^0.2.3", From ff4c49b29785d2f69ede986665e9b2caf25ec682 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:24:44 -0500 Subject: [PATCH 11/16] Convert watch grunt task to npm script --- Gruntfile.js | 13 ++----------- package.json | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ae333a8..05c2f35 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -53,23 +53,14 @@ module.exports = function (grunt) { } }, - 'watch': { - options: { - livereload: true - }, - build: { - files: 'src/**/*.js', - tasks: ['webpack'] - } - }, - 'exec': { + watch: pkgConfig.scripts.watch, launch_nw: '/Applications/nwjs.app/Contents/MacOS/nwjs dist' }, 'concurrent': { target: { - tasks: ['watch', 'exec:launch_nw'], + tasks: ['exec:watch', 'exec:launch_nw'], options: { logConcurrentOutput: true } diff --git a/package.json b/package.json index af78fdc..e9d105a 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "serve-web": "grunt serve-web", "serve-web:dist": "grunt serve-web:dist", "start": "node_modules/react-native/packager/packager.sh", - "test": "`npm bin`/jest" + "test": "`npm bin`/jest", + "watch": "`npm bin`/webpack --config webpack.config.js --watch" }, "jest": { "scriptPreprocessor": "/node_modules/babel-jest", @@ -76,7 +77,6 @@ "grunt": "^0.4.5", "grunt-concurrent": "^2.0.4", "grunt-contrib-clean": "^0.6.0", - "grunt-contrib-watch": "^0.6.1", "grunt-exec": "^0.4.6", "grunt-open": "^0.2.3", "grunt-webpack": "^1.0.11", From 615799f8bd990172755af9434d422dfce11183b8 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:24:54 -0500 Subject: [PATCH 12/16] Add npm clean script --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index e9d105a..633f0ff 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "dist": "./dist", "scripts": { "build": "grunt build", + "clean": "`npm bin`/rimraf dist", "deploy": "gh-pages -d dist", "karma": "`npm bin`/karma start", "travis": "npm run build && npm run react-native:ios && npm run react-native:android && npm test", @@ -96,6 +97,7 @@ "node-sass": "^3.4.1", "phantomjs": "^1.9.18", "react-hot-loader": "^1.3.0", + "rimraf": "^2.4.3", "sass-loader": "^3.1.1", "style-loader": "^0.13.0", "url-loader": "^0.5.6", From 71f1ba131998134c922451ac0dec31de0e48bfb3 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:25:08 -0500 Subject: [PATCH 13/16] Convert build grunt task to npm script --- Gruntfile.js | 24 ------------------------ README.md | 8 ++++---- package.json | 7 +------ 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 05c2f35..853eb10 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,6 +1,5 @@ 'use strict'; -var webpackDistConfig = require('./webpack.dist.config.js'); var webpackDevConfig = require('./webpack.hot.config.js'); module.exports = function (grunt) { @@ -13,13 +12,6 @@ module.exports = function (grunt) { grunt.initConfig({ 'pkg': pkgConfig, - 'webpack': { - options: webpackDistConfig, - dist: { - cache: false - } - }, - 'webpack-dev-server': { options: { hot: true, @@ -42,17 +34,6 @@ module.exports = function (grunt) { } }, - 'clean': { - dist: { - files: [{ - dot: true, - src: [ - '<%= pkg.dist %>' - ] - }] - } - }, - 'exec': { watch: pkgConfig.scripts.watch, launch_nw: '/Applications/nwjs.app/Contents/MacOS/nwjs dist' @@ -69,10 +50,6 @@ module.exports = function (grunt) { }); grunt.registerTask('serve-web', function (target) { - if (target === 'dist') { - return grunt.task.run(['build', 'open:dist']); - } - grunt.task.run([ 'open:dist', 'webpack-dev-server' @@ -85,6 +62,5 @@ module.exports = function (grunt) { ]); }); - grunt.registerTask('build', ['clean', 'webpack']); grunt.registerTask('default', []); }; diff --git a/README.md b/README.md index 06caff2..1e071bb 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ This project uses libraries and tools like: - [NW](http://nwjs.io) to package the Desktop App - [flux](https://facebook.github.io/flux) to organize the data flow management - [css-loader](https://github.com/webpack/css-loader) to integrate the styles in the builds -- [grunt](http://gruntjs.com) to create the builds -- [webpack](https://webpack.github.io) to help during the development phase with hot reloading +- [grunt](http://gruntjs.com) to launch NW.js or your web browser +- [webpack](https://webpack.github.io) to create the builds and help during the development phase with hot reloading ## Basic philosophy @@ -148,7 +148,7 @@ There isn't any addtional requirements since you already installed the deps with ### Quick start -- `npm run build` to build the project (at least the first time) +- `npm run build` to build the project - `npm run serve-web` to preview in the browser at http://localhost:8000/ with webpack-dev-server and hot reload enabled Congratulations! You've just successfully run the project as a Website App. @@ -171,7 +171,7 @@ You can also setup an alias to call the binary. ### Quick start -- `npm run build` to build the project (at least the first time) +- `npm run build` to build the project - `npm run serve-nw` to launch the desktop app and enable livereload Congratulations! You've just successfully run the project as a Desktop App. diff --git a/package.json b/package.json index 633f0ff..2719c81 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,8 @@ "flux", "babel" ], - "src": "./", - "test": "./test", - "dist": "./dist", "scripts": { - "build": "grunt build", + "build": "npm run clean && `npm bin`/webpack --config webpack.dist.config.js", "clean": "`npm bin`/rimraf dist", "deploy": "gh-pages -d dist", "karma": "`npm bin`/karma start", @@ -77,10 +74,8 @@ "gh-pages": "^0.5.0", "grunt": "^0.4.5", "grunt-concurrent": "^2.0.4", - "grunt-contrib-clean": "^0.6.0", "grunt-exec": "^0.4.6", "grunt-open": "^0.2.3", - "grunt-webpack": "^1.0.11", "html-webpack-plugin": "^1.6.2", "jasmine-core": "^2.3.4", "jest-cli": "^0.7.1", From 82543850f32b66ec5c4d1299fdf9eaaeeb330e25 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:25:18 -0500 Subject: [PATCH 14/16] Convert web server grunt task to npm script --- Gruntfile.js | 18 ++---------------- package.json | 1 + 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 853eb10..e2d7912 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,7 +1,5 @@ 'use strict'; -var webpackDevConfig = require('./webpack.hot.config.js'); - module.exports = function (grunt) { // Let *load-grunt-tasks* require everything require('load-grunt-tasks')(grunt); @@ -12,19 +10,6 @@ module.exports = function (grunt) { grunt.initConfig({ 'pkg': pkgConfig, - 'webpack-dev-server': { - options: { - hot: true, - port: 8000, - webpack: webpackDevConfig, - contentBase: './dist/' - }, - - start: { - keepAlive: true - } - }, - 'open': { options: { delay: 500 @@ -36,6 +21,7 @@ module.exports = function (grunt) { 'exec': { watch: pkgConfig.scripts.watch, + server: pkgConfig.scripts.server, launch_nw: '/Applications/nwjs.app/Contents/MacOS/nwjs dist' }, @@ -52,7 +38,7 @@ module.exports = function (grunt) { grunt.registerTask('serve-web', function (target) { grunt.task.run([ 'open:dist', - 'webpack-dev-server' + 'exec:server' ]); }); diff --git a/package.json b/package.json index 2719c81..a72cff0 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "clean": "`npm bin`/rimraf dist", "deploy": "gh-pages -d dist", "karma": "`npm bin`/karma start", + "server": "`npm bin`/webpack-dev-server --config ./webpack.hot.config.js --content-base ./dist/ --port 8000 --inline --hot --progress", "travis": "npm run build && npm run react-native:ios && npm run react-native:android && npm test", "react-native:ios": "react-native bundle --root src --platform ios --minify", "react-native:android": "react-native bundle --root src --platform android --minify", From 17f60d1ae11fd3785f27b4bc8bdeadb6ffccf3de Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:25:26 -0500 Subject: [PATCH 15/16] Remove unused jshint dependencies --- package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/package.json b/package.json index a72cff0..20a7ef1 100644 --- a/package.json +++ b/package.json @@ -80,8 +80,6 @@ "html-webpack-plugin": "^1.6.2", "jasmine-core": "^2.3.4", "jest-cli": "^0.7.1", - "jshint": "^2.8.0", - "jshint-loader": "^0.8.3", "karma": "^0.13.15", "karma-chrome-launcher": "^0.2.1", "karma-firefox-launcher": "^0.1.6", From 48b38fecf5b2ff3e7c98760578da89b7f08382a2 Mon Sep 17 00:00:00 2001 From: Serge Paquet Date: Sat, 7 Nov 2015 19:52:00 -0500 Subject: [PATCH 16/16] Specify absolute path to webpack output directory --- webpack.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 0f587db..ac1cb3f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,6 +4,7 @@ 'use strict'; +var path = require('path'); var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { @@ -15,7 +16,7 @@ module.exports = { output: { filename: 'assets/main.js', - path: 'dist/' + path: path.join(__dirname, 'dist') }, stats: {