Skip to content

Commit

Permalink
added production build task
Browse files Browse the repository at this point in the history
  • Loading branch information
Vvv committed Jul 25, 2016
1 parent 718b2a3 commit c4b6474
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 19 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Sails-React-Webpack Starter Kit

Apart from [this Sails-React starter kit](https://github.com/mixxen/sails-react-example) this one fully uses [Webpack](http://webpack.github.io) as a separate grunt build task. Also I have stepped out from using [Bower](https://bower.io) as front-end package manager and left all to `npm` so if you need any additional package that you want to `import` to your React app, use `npm`.
Apart from [this Sails-React starter kit](https://github.com/mixxen/sails-react-example) this one fully uses [Webpack](http://webpack.github.io) as a separate grunt build task. Also I have stepped out from using [Bower](https://bower.io) as front-end package manager and left all to `npm` so if you need any additional package that you want to `import` to your **React** app, use `npm`.

Upon navigating to `/` an `index.jade` view will be shown that starts React application. All React application code is located at `assets/app`.
Upon navigating to `/` an `index.jade` view will be shown that starts **React** application. All **React** application code is located at `assets/app`.

In order to modify grunt task that bundles React code look at `tasks/config/webpack.js`.
In order to modify grunt task that bundles **React** code look at `tasks/config/webpack.js`.




### Installation

- Clone this repo.
- run `npm install`
- run `npm run dev` to start sails server.
- run `npm install` to scaffold up dependencies
- run `npm run dev` to start Sails server in `development` mode
- run `npm run prod` to start Sails server in `production` mode




### Licence

MIT
MIT
7 changes: 7 additions & 0 deletions config/env/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,12 @@ module.exports = {
// models: {
// connection: 'someMongodbServer'
// }

/**
* Here we increase hoot timeout for grunt so that it won't cry on slow machines
*/
grunt: {
_hookTimeout: 80000
}

};
7 changes: 7 additions & 0 deletions config/env/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@ module.exports = {
// log: {
// level: "silent"
// }

/**
* Here we increase hoot timeout for grunt so that it won't cry on slow machines
*/
grunt: {
_hookTimeout: 80000
}

};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"webpack-dev-server": "^1.14.1"
},
"scripts": {
"dev": "clear && sails lift --verbose"
"dev": "clear && sails lift --verbose",
"prod": "clear && sails lift --prod"
},
"main": "app.js",
"repository": {
Expand Down
45 changes: 34 additions & 11 deletions tasks/config/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ var path = require("path");
var project_dir = __dirname + '/../../';
var webpack = require("webpack");

var prod = process.env.NODE_ENV && process.env.NODE_ENV === 'production';

var pluggins = [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin()
];

if (prod)
pluggins.push(new webpack.optimize.UglifyJsPlugin({
mangle: true,
sourcemap: false,
minimize: true,
}));

module.exports = function(grunt) {
grunt.config.set('webpack', {
dev: {
Expand All @@ -25,23 +39,32 @@ module.exports = function(grunt) {
},
output: {
path: ".tmp/public/js",
filename: "app.min.js"
filename: prod ? "app.min.js" : "app.js"
},
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.optimize.UglifyJsPlugin({
// mangle: true,
// sourcemap: false
// }),
],

plugins: pluggins,

hot: false,
inline: false,
keepalive: false,
stats: false,
watch: false,
progress: false,

stats: {
colors: true,
hash: false,
version: false,
timings: true,
assets: true,
chunks: true,
modules: true,
reasons: false,
children: false,
source: false,
errors: false,
errorDetails: false,
warnings: false,
publicPath: false
}
}
});

Expand Down

0 comments on commit c4b6474

Please sign in to comment.