build new client in production

This commit is contained in:
Matteo Pagliazzi
2016-09-21 14:37:44 +02:00
parent f751ccacc5
commit 12275cc174
5 changed files with 1395 additions and 153 deletions

View File

@@ -146,6 +146,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-hashres');
grunt.loadNpmTasks('grunt-karma');
if (process.env.NODE_ENV !== 'production') grunt.loadNpmTasks('grunt-karma');
};

1472
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,10 @@
"apidoc": "^0.16.0",
"apn": "^1.7.6",
"async": "^1.5.0",
"autoprefixer": "^6.4.0",
"aws-sdk": "^2.0.25",
"babel-loader": "^6.0.0",
"babel-core": "^6.0.0",
"babel-plugin-transform-async-to-module-method": "^6.8.0",
"babel-polyfill": "^6.6.1",
"babel-preset-es2015": "^6.6.0",
@@ -26,6 +29,7 @@
"connect-ratelimit": "0.0.7",
"cookie-session": "^1.2.0",
"coupon-code": "^0.4.3",
"css-loader": "^0.23.1",
"csv-stringify": "^1.0.2",
"cwait": "^1.0.0",
"domain-middleware": "~0.1.0",
@@ -33,6 +37,8 @@
"express": "~4.13.3",
"express-csv": "~0.6.0",
"express-validator": "^2.18.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.4",
"glob": "^4.3.5",
"got": "^6.1.1",
"grunt": "~0.4.1",
@@ -44,7 +50,6 @@
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-hashres": "~0.4.1",
"grunt-karma": "~0.12.1",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.2",
"gulp-grunt": "^0.5.2",
@@ -54,10 +59,12 @@
"gulp-uglify": "^1.4.2",
"gulp.spritesmith": "^4.1.0",
"habitica-markdown": "^1.3.0",
"html-webpack-plugin": "^2.8.1",
"image-size": "~0.3.2",
"in-app-purchase": "^1.1.6",
"jade": "~1.11.0",
"js2xmlparser": "~1.0.0",
"json-loader": "^0.5.4",
"lodash": "^3.10.1",
"lodash.setwith": "^4.2.0",
"merge-stream": "^1.0.0",
@@ -72,6 +79,7 @@
"node-gcm": "^0.14.4",
"nodemailer": "^2.3.2",
"object-path": "^0.9.2",
"ora": "^0.2.0",
"pageres": "^4.1.1",
"passport": "~0.2.1",
"passport-facebook": "2.0.0",
@@ -79,6 +87,7 @@
"paypal-rest-sdk": "^1.2.1",
"pretty-data": "^0.40.0",
"ps-tree": "^1.0.0",
"pug": "^2.0.0-beta6",
"push-notify": "habitrpg/push-notify#v1.2.0",
"pusher": "^1.3.0",
"request": "~2.72.0",
@@ -86,18 +95,23 @@
"run-sequence": "^1.1.4",
"s3-upload-stream": "^1.0.6",
"serve-favicon": "^2.3.0",
"shelljs": "^0.6.0",
"stripe": "^4.2.0",
"superagent": "^1.8.3",
"universal-analytics": "~0.3.2",
"url-loader": "^0.5.7",
"useragent": "2.1.9",
"uuid": "^2.0.1",
"validator": "^4.9.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"vue": "^2.0.0-rc.6",
"vue-loader": "^9.4.0",
"vue-router": "^2.0.0-rc.5",
"vuex": "^2.0.0-rc.5",
"vuex-router-sync": "^3.0.0",
"webpack": "^1.12.2",
"webpack-merge": "^0.8.3",
"winston": "^2.1.0",
"xml2js": "^0.4.4"
},
@@ -122,21 +136,18 @@
"test:e2e:webdriver": "webdriver-manager start",
"test:e2e": "protractor test/client-old/e2e/protractor.conf.js",
"test:nodemon": "gulp test:nodemon",
"start": "gulp run:dev",
"sprites": "gulp sprites:compile",
"postinstall": "bower --config.interactive=false install -f; gulp build;",
"coverage": "COVERAGE=true mocha --require register-handlers.js --reporter html-cov > coverage.html; open coverage.html",
"sprites": "gulp sprites:compile",
"client:dev": "node webpack/dev-server.js",
"client:build": "node webpack/build.js",
"client:unit": "karma start test/client/unit/karma.conf.js --single-run",
"client:e2e": "node test/client/e2e/runner.js",
"client:test": "npm run client:unit && npm run client:e2e"
"client:test": "npm run client:unit && npm run client:e2e",
"start": "gulp run:dev",
"postinstall": "bower --config.interactive=false install -f; gulp build; npm run client:build"
},
"devDependencies": {
"autoprefixer": "^6.4.0",
"babel-core": "^6.0.0",
"babel-eslint": "^6.0.0",
"babel-loader": "^6.0.0",
"chai": "^3.4.0",
"chai-as-promised": "^5.1.0",
"chalk": "^1.1.3",
@@ -144,7 +155,6 @@
"connect-history-api-fallback": "^1.1.0",
"coveralls": "^2.11.2",
"cross-spawn": "^2.1.5",
"css-loader": "^0.23.0",
"csv": "~0.3.6",
"deep-diff": "~0.1.4",
"eslint": "~2.12.0",
@@ -157,14 +167,11 @@
"event-stream": "^3.2.2",
"eventsource-polyfill": "^0.9.6",
"expect.js": "~0.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.4",
"html-webpack-plugin": "^2.8.1",
"grunt-karma": "~0.12.1",
"http-proxy-middleware": "^0.12.0",
"inject-loader": "^2.0.1",
"isparta-loader": "^2.0.0",
"istanbul": "^0.3.14",
"json-loader": "^0.5.4",
"karma": "^1.3.0",
"karma-babel-preprocessor": "^6.0.1",
"karma-chai-plugins": "~0.6.0",
@@ -182,25 +189,18 @@
"mongodb": "^2.0.46",
"mongoskin": "~2.1.0",
"nightwatch": "^0.8.18",
"ora": "^0.2.0",
"phantomjs-prebuilt": "^2.1.12",
"protractor": "^3.1.1",
"pug": "^2.0.0-beta6",
"require-again": "^2.0.0",
"rewire": "^2.3.3",
"selenium-server": "2.53.0",
"shelljs": "^0.6.0",
"sinon": "^1.17.2",
"sinon-chai": "^2.8.0",
"superagent-defaults": "^0.1.13",
"url-loader": "^0.5.7",
"vinyl-source-stream": "^1.0.0",
"vinyl-transform": "^1.0.0",
"vue-hot-reload-api": "^1.2.0",
"vue-loader": "^9.4.0",
"webpack": "^1.12.2",
"webpack-dev-middleware": "^1.4.0",
"webpack-hot-middleware": "^2.6.0",
"webpack-merge": "^0.8.3"
"webpack-hot-middleware": "^2.6.0"
}
}

View File

@@ -3,42 +3,43 @@ var config = require('./config');
var utils = require('./utils');
var projectRoot = path.resolve(__dirname, '../');
module.exports = {
var IS_PROD = process.env.NODE_ENV === 'production';
var baseConfig = {
entry: {
app: './website/client/main.js',
},
output: {
path: config.build.assetsRoot,
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
publicPath: IS_PROD ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
filename: '[name].js',
},
resolve: {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'src': path.resolve(__dirname, '../website/client'),
'assets': path.resolve(__dirname, '../website/client/assets'),
'components': path.resolve(__dirname, '../website/client/components'),
src: path.resolve(__dirname, '../website/client'),
assets: path.resolve(__dirname, '../website/client/assets'),
components: path.resolve(__dirname, '../website/client/components'),
},
},
resolveLoader: {
fallback: [path.join(__dirname, '../node_modules')],
},
module: {
preLoaders: [
preLoaders: !IS_PROD ? [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
exclude: /node_modules/,
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
exclude: /node_modules/,
},
] : [],
loaders: [
{
test: /\.vue$/,
@@ -72,9 +73,6 @@ module.exports = {
},
],
},
eslint: {
formatter: require('eslint-friendly-formatter'),
},
vue: {
loaders: utils.cssLoaders(),
postcss: [
@@ -84,3 +82,10 @@ module.exports = {
],
},
};
if (!IS_PROD) {
baseConfig.eslint = {
formatter: require('eslint-friendly-formatter'),
};
}
module.exports = baseConfig;

View File

@@ -91,6 +91,7 @@ if (IS_PROD && IS_NEW_CLIENT_ENABLED) {
method: 'GET',
url: /^\/new-app($|\/(?!(static\/.?|static$)))/,
async handler (req, res) {
console.log(req.session, req.session.userId)
if (!(req.session && req.session.userId)) {
return res.redirect('/static/front');
}