From 5e230fb65c81b26e0ce0f68987c79a3437d1d3ba Mon Sep 17 00:00:00 2001 From: Ilia Isupov Date: Tue, 15 Mar 2016 23:06:05 +0300 Subject: [PATCH 1/3] Webpack setup --- .gitignore | 2 +- package.json | 7 ++++--- webpack.config.js | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index 91dd14b..7b1fb76 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ node_modules coverage /lib/static/client.js -/lib/static/client.js.map.json +/lib/static/client.js.map diff --git a/package.json b/package.json index 5ac3835..ba81a11 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "gemini-gui": "./bin/gemini-gui" }, "scripts": { - "build-client": "browserify lib/client --debug -p [minifyify --compressPath . --map /client.js.map.json --output ./lib/static/client.js.map.json] -t hbsfy -o ./lib/static/client.js", + "build-client": "webpack", "prepublish": "npm run build-client", "test": "istanbul test _mocha --require ./test/setup.js test/*", "lint": "jshint . && jscs ." @@ -32,11 +32,12 @@ "temp": "^0.8.1" }, "devDependencies": { - "browserify": "^5.11.1", + "babel-loader": "^6.2.4", "chai": "^3.5.0", "chai-as-promised": "^5.2.0", "dirty-chai": "^1.2.2", "gemini": "^2.1.0", + "handlebars-loader": "^1.1.4", "hbsfy": "^2.1.0", "istanbul": "^0.3.2", "jscs": "^1.6.2", @@ -46,7 +47,7 @@ "proxyquire": "^1.7.3", "sinon": "^1.17.3", "sinon-chai": "^2.8.0", - "watchify": "^1.0.2" + "webpack": "^1.12.14" }, "directories": { "test": "test" diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..8f6f1b3 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,40 @@ +var webpack = require('webpack'); + +module.exports = { + debug: false, + devtool: 'source-map', + entry: './lib/client', + output: { + path: './lib/static', + filename: 'client.js' + }, + plugins: [ + new webpack.optimize.CommonsChunkPlugin({ + name: 'main', + children: true, + minChunks: 2 + }), + new webpack.optimize.DedupePlugin(), + new webpack.optimize.OccurenceOrderPlugin(), + new webpack.optimize.MinChunkSizePlugin({ minChunkSize: 51200 }), + new webpack.optimize.UglifyJsPlugin({ + mangle: true, + compress: { + warnings: false // Suppress uglification warnings + } + }) + ], + module: { + loaders: [ + { + test: /\.js/, + loader: 'babel', + inclue: __dirname + '/lib/client' + }, + { + test: /\.hbs/, + loader: 'handlebars' + } + ] + } +}; From 482e7e32066a2ff5411f79b9eeee5869b1fc58d7 Mon Sep 17 00:00:00 2001 From: Ilia Isupov Date: Wed, 16 Mar 2016 22:42:54 +0300 Subject: [PATCH 2/3] Fixup. Added husky --- package.json | 5 ++++- webpack.config.js | 12 +++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index ba81a11..019e986 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "build-client": "webpack", "prepublish": "npm run build-client", "test": "istanbul test _mocha --require ./test/setup.js test/*", - "lint": "jshint . && jscs ." + "lint": "jshint . && jscs .", + "precommit": "npm run lint", + "preversion": "npm run lint && npm test" }, "author": "Sergey Tatarintsev (https://github.com/SevInf)", "license": "MIT", @@ -39,6 +41,7 @@ "gemini": "^2.1.0", "handlebars-loader": "^1.1.4", "hbsfy": "^2.1.0", + "husky": "^0.11.3", "istanbul": "^0.3.2", "jscs": "^1.6.2", "jshint": "^2.5.6", diff --git a/webpack.config.js b/webpack.config.js index 8f6f1b3..77d3bee 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,14 +9,8 @@ module.exports = { filename: 'client.js' }, plugins: [ - new webpack.optimize.CommonsChunkPlugin({ - name: 'main', - children: true, - minChunks: 2 - }), new webpack.optimize.DedupePlugin(), new webpack.optimize.OccurenceOrderPlugin(), - new webpack.optimize.MinChunkSizePlugin({ minChunkSize: 51200 }), new webpack.optimize.UglifyJsPlugin({ mangle: true, compress: { @@ -27,12 +21,12 @@ module.exports = { module: { loaders: [ { - test: /\.js/, + test: /\.js$/, loader: 'babel', - inclue: __dirname + '/lib/client' + include: __dirname + '/lib/client' }, { - test: /\.hbs/, + test: /\.hbs$/, loader: 'handlebars' } ] From d555ee78803588cca743fc3291ededeff45f54cf Mon Sep 17 00:00:00 2001 From: Ilia Isupov Date: Wed, 16 Mar 2016 23:32:15 +0300 Subject: [PATCH 3/3] Added react related presets, now will transpile .jsx correctly --- package.json | 5 +++++ webpack.config.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 019e986..5ee185b 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,17 @@ "opener": "^1.4.0", "q": "^1.0.1", "q-io": "^1.11.4", + "react": "^0.14.7", + "react-dom": "^0.14.7", "resolve": "^1.0.0", "semver": "^3.0.1", "temp": "^0.8.1" }, "devDependencies": { + "babel-core": "^6.7.2", "babel-loader": "^6.2.4", + "babel-preset-es2015": "^6.6.0", + "babel-preset-react": "^6.5.0", "chai": "^3.5.0", "chai-as-promised": "^5.2.0", "dirty-chai": "^1.2.2", diff --git a/webpack.config.js b/webpack.config.js index 77d3bee..bfd5ce2 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -16,14 +16,22 @@ module.exports = { compress: { warnings: false // Suppress uglification warnings } + }), + new webpack.DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify('production') + } }) ], module: { loaders: [ { - test: /\.js$/, + test: /\.(js|jsx)$/, loader: 'babel', - include: __dirname + '/lib/client' + include: __dirname + '/lib/client', + query: { + presets: ['es2015', 'react'] + } }, { test: /\.hbs$/,