Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node production mode #94

Closed
darxx opened this issue Jun 7, 2016 · 5 comments
Closed

node production mode #94

darxx opened this issue Jun 7, 2016 · 5 comments

Comments

@darxx
Copy link
Contributor

darxx commented Jun 7, 2016

<Have you checked issues section which may have your similar issue?>

Issue Overview

If You are running npm install --production
You don`t have all needed node module to make production build on linux agent.

If You make only npm install. You are installing all packages not needed for production. Like:
browser-sync
connect-history-api-fallback

Issue Description

gulp.config strongly banded to gulp.config.js

  • var historyApiFallback = require('connect-history-api-fallback');

And no production logic is separated. If You are following best practice installing only node mode that are required for each environment.

Reproducables

npm install --production
gulp build --exclude-source

Information

Operating System Debian
Node version 4.x/5.x/orYourNodeVersionHere
Environment Browser/Mobile/WebWorker
@antonybudianto7 antonybudianto7 changed the title Not production ready node production mode Jun 7, 2016
@antonybudianto7
Copy link
Collaborator

antonybudianto7 commented Jun 7, 2016

Thanks, I'd love to accept a PR for this.

I updated the title to reflect the real issue, since the production build is okay, but not "node best practice"

@darxx
Copy link
Contributor Author

darxx commented Jun 7, 2016

I did node production mode. For angular 1.X examples can be taken from https://github.com/darxx/AngularWorkshop/tree/step6

@antonybudianto7
Copy link
Collaborator

@darxx , can you send a PR? I'll help where I can

@darxx
Copy link
Contributor Author

darxx commented Jun 7, 2016

Yes. After work I will try to figure it out. Now I`m thinking to use global.env and separate gulp.config.js part that is using
if (global.env === 'dev') {
var historyApiFallback = require('connect-history-api-fallback');
}

module.exports = function () {

And
if (global.env === 'dev')
{
var browserSync = {
dev: {
port: 3000,
server: {
baseDir: './src/',
middleware: [historyApiFallback()],
routes: {
"/node_modules": "node_modules",
"/src": "src"
}
},
files: [
src + "index.html",
src + "systemjs.conf.js",
src + "assets/styles/main.css",
tmpApp + "/*.js",
app + "
/.css",
app + "__/
.html"
]
},
prod: {
port: 3001,
server: {
baseDir: './' + build.path,
middleware: [historyApiFallback()]
}
}
};
}

and

var config = {
root: root,
translations: translations,
src: src,
app: app,
test: test,
tmp: tmp,
tmpApp: tmpApp,
tmpTest: tmpTest,
tmpE2E: tmpE2E,
testHelper: testHelper,
e2e: e2e,
e2eConfig: e2eConfig,
assets: assets,
index: index,
build: build,
report: report,
assetsPath: assetsPath,
tsFiles: tsFiles,
tsTestFiles: tsTestFiles,
systemJs: systemJs
};

if (global.env === 'dev')
{
    config.browserSync = browserSync;

}

And now I`m getting

07 06 2016 15:34:03.353:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
07 06 2016 15:34:03.363:INFO [launcher]: Starting browser PhantomJS
07 06 2016 15:34:04.918:INFO [PhantomJS 2.1.1 (Windows 8 0.0.0)]: Connected on socket /#2elfkEsL-DS8sZ26AAAA with id 62765646
07 06 2016 15:34:07.171:WARN [web-server]: 404: /base/node_modules/karma-ie-launcher/test/launcher.spec
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
Error: XHR error (404 Not Found) loading http://localhost:9876/node_modules/karma-ie-launcher/test/launcher.spec
Error loading http://localhost:9876/node_modules/karma-ie-launcher/test/launcher.spec

Remapping coverage to TypeScript format...
Test Done with exit code: 1
[15:34:07] 'unit-test' errored after 26 s
[15:34:07] Error: 1
at formatError (C:\Users\darlau\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:169:10)
at Gulp. (C:\Users\darlau\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js:195:15)
at emitOne (events.js:95:20)
at Gulp.emit (events.js:182:7)
at Gulp.Orchestrator._emitTaskDone (C:\dev\coreUI\node_modules\orchestrator\index.js:264:8)
at C:\dev\coreUI\node_modules\orchestrator\index.js:275:23
at finish (C:\dev\coreUI\node_modules\orchestrator\lib\runTask.js:21:8)
at cb (C:\dev\coreUI\node_modules\orchestrator\lib\runTask.js:29:3)
at DestroyableTransform. (C:\dev\coreUI\tasks\test.js:59:13)
at emitNone (events.js:85:20)
at DestroyableTransform.emit (events.js:179:7)
at finishMaybe (C:\dev\coreUI\node_modules\through2\node_modules\readable-stream\lib_stream_writable.js:475:14)
at endWritable (C:\dev\coreUI\node_modules\through2\node_modules\readable-stream\lib_stream_writable.js:485:3)
at DestroyableTransform.Writable.end (C:\dev\coreUI\node_modules\through2\node_modules\readable-stream\lib_stream_writable.js:455:41)
at DestroyableTransform.onend (C:\dev\coreUI\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:523:10)
at DestroyableTransform.g (events.js:273:16)
at emitNone (events.js:85:20)
at DestroyableTransform.emit (events.js:179:7)
at C:\dev\coreUI\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:965:16
at _combinedTickCallback (node.js:376:9)
at process._tickCallback (node.js:407:11)
[15:34:07] 'build' errored after 31 s
[15:34:07] Error in plugin 'run-sequence(unit-test)'
Message:
unit-test callback
Remapping done! View the result in report/remap/html-report

At home I will have more time to figure it out.

@darxx
Copy link
Contributor Author

darxx commented Jun 7, 2016

gulp build --exclude-source --prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants