Anybody can help me?
How to build only one bundle.js with angular 8 ? Lots of javascript files were created when I executed "npm run build". (e.g main.js/runtime.js/polyfills.js/...)
I hope that all of them(main.js/runtime.js/polyfills.js/) can output to bundle.js
Here is my packages.json:
{
"name": "buy-me",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --aot --build-optimizer --base-href /buyme/ --deploy-url /buyme/",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-devkit/core": "^8.0.1",
"#angular/animations": "^8.0.0",
"#angular/common": "^8.0.0",
"#angular/compiler": "^8.0.0",
"#angular/core": "^8.0.0",
"#angular/forms": "^8.0.0",
"#angular/platform-browser": "^8.0.0",
"#angular/platform-browser-dynamic": "^8.0.0",
"#angular/router": "^8.0.0",
"core-js": "^3.1.3",
"ngx-markdown": "^8.0.1",
"rxjs": "^6.5.2",
"rxjs-compat": "^6.5.2",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.800.1",
"#angular/cli": "^8.0.1",
"#angular/compiler-cli": "^8.0.0",
"#angular/language-service": "^8.0.0",
"#types/jasmine": "~3.3.13",
"#types/jasminewd2": "~2.0.6",
"#types/node": "~12.0.4",
"codelyzer": "^5.0.1",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~2.0.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.2",
"ts-node": "~8.2.0",
"tslint": "~5.17.0",
"typescript": "^3.4.5"
}
}
I tried but output files like main.js, polyfills.js, runtime.js and so on, I hope that these can be concat one bundle.js.
With Angular 8 you don't have to bundle those files together. But if you want, the following steps will help you with that:
Install concat package into your project
Add the following lines to your package.json's "scripts" section:
"concat:es-5": "concat -o ./dist/ng-test-proj/bundle-es5.js ./dist/ng-test-proj/main-es5.*.js ./dist/ng-test-proj/polyfills-es5.*.js ./dist/ng-test-proj/runtime-es5.*.js",
"concat:es-2015": "concat -o ./dist/ng-test-proj/bundle-2015.js ./dist/ng-test-proj/main-es2015.*.js ./dist/ng-test-proj/polyfills-es2015.*.js ./dist/ng-test-proj/runtime-es2015.*.js",
"build:prod": "ng build -c production",
"build:prod:bundle": "npm run build:prod && npm run concat:es-5 && npm run concat:es-2015",
Now you can execute "npm run build:prod:bundle" in a terminal and you will get two bundle files.
As a last step, your HTML file should be updated (it should has links to those bundles if you want to use them instead of original files).
Related
My Angular 9 Universal app is running smoothly locally. But I can't run it with serverless-offline. I am getting this error:
{
currentRoute: "get - /",
error: "Serverless-offline: route not found.",
existingRoutes: [
"* - /production",
"* - /production/{proxy*}"
],
statusCode: 404
}
Here is my serverless.yml code, generated by #ng-toolkit/serverless:
# generated by #ng-toolkit/serverless
service: brmed
plugins:
- serverless-apigw-binary
- serverless-offline
provider:
name: aws
runtime: nodejs12.x
memorySize: 192
timeout: 30
stage: production
region: us-east-2
package:
exclude:
- src/**
- node_modules/**
- firebug-lite/**
- e2e/**
- coverage/**
- '!node_modules/aws-serverless-express/**'
- '!node_modules/binary-case/**'
- '!node_modules/type-is/**'
- '!node_modules/media-typer/**'
- '!node_modules/mime-types/**'
- '!node_modules/mime-db/**'
custom:
apigwBinary:
types:
- '*/*'
serverless-offline:
httpPort: 8181
functions:
api:
handler: lambda.universal
events:
- http: ANY {proxy+}
- http: ANY /
Here is my package.json file:
{
"name": "brmed",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --build-optimizer --output-path=\"dist/BRMed/browser",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"dev:ssr": "ng run BRMed:serve-ssr",
"serve:ssr": "serverless offline start",
"build:ssr": "ng build --prod && ng run BRMed:server:production",
"prerender": "ng run BRMed:prerender",
"build:browser:prod": "ng build --prod",
"build:browser:serverless": "ng build --prod --base-href /production/",
"build:serverless": "npm run build:browser:serverless && npm run build:server:serverless",
"build:prod": "npm run build:browser:prod && npm run build:server:prod",
"build:prod:deploy": "npm run build:prod && npm run deploy",
"build:serverless:deploy": "npm run build:serverless && npm run deploy",
"deploy": "serverless deploy",
"terminate": "serverless remove",
"server": "node local.js",
"build:server:prod": "ng run BRMed:server && webpack --config webpack.server.config.js --progress --colors",
"build:server:serverless": "ng run BRMed:server:serverless && webpack --config webpack.server.config.js --progress --colors"
},
"private": true,
"dependencies": {
"#agm/core": "^1.0.0-beta.7",
"#angular/animations": "^9.0.2",
"#angular/cdk": "^9.0.1",
"#angular/common": "^9.0.2",
"#angular/compiler": "^9.0.2",
"#angular/forms": "^9.0.2",
"#angular/localize": "^9.0.2",
"#angular/material": "^9.0.1",
"#angular/platform-browser": "^9.0.2",
"#angular/platform-browser-dynamic": "^9.0.2",
"#angular/router": "^9.0.2",
"#fortawesome/angular-fontawesome": "^0.6.0",
"#fortawesome/fontawesome-svg-core": "^1.2.27",
"#fortawesome/free-brands-svg-icons": "^5.12.1",
"#fortawesome/free-regular-svg-icons": "^5.12.1",
"#fortawesome/free-solid-svg-icons": "^5.12.1",
"#ng-bootstrap/ng-bootstrap": "^4.1.0",
"#ng-toolkit/serverless": "^8.0.3",
"#nguniversal/express-engine": "^9.0.1",
"#nguniversal/module-map-ngfactory-loader": "^8.2.6",
"#sentry/browser": "^5.12.4",
"#types/googlemaps": "^3.39.3",
"angular-gauge-chart": "^0.7.2",
"angular-google-charts": "^0.1.6",
"angular2-text-mask": "^9.0.0",
"aws-serverless-express": "^3.2.0",
"bootstrap": "^4.3.1",
"core-js": "^2.5.4",
"cors": "~2.8.4",
"cp-cli": "^1.1.0",
"express": "^4.15.2",
"hammerjs": "^2.0.8",
"intersection-observer": "^0.7.0",
"jquery": "^1.9.1",
"ng-intercom": "^8.0.2",
"ng-lazyload-image": "^6.1.0",
"ngx-device-detector": "^1.3.11",
"node-sass": "^4.13.0",
"popper.js": "^1.14.7",
"postcss": "^7.0.27",
"rxjs": "~6.5.4",
"serverless": "^1.64.1",
"serverless-http": "^2.3.2",
"tslib": "^1.11.0",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11",
"ws": "^7.1.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.900.3",
"#angular/cli": "^9.0.3",
"#angular/compiler-cli": "^9.0.2",
"#angular/core": "^9.0.2",
"#angular/language-service": "^9.0.2",
"#angular/platform-server": "^9.0.0",
"#nguniversal/builders": "^9.0.1",
"#types/express": "^4.17.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^8.9.5",
"#types/stripe-v3": "^3.1.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"opencollective": "^1.0.3",
"protractor": "~5.4.0",
"serverless-apigw-binary": "^0.4.4",
"serverless-offline": "^6.0.0-alpha.67",
"ts-loader": "4.2.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "^3.7.5"
}
}
I researched online a lot to find the solution for this problem, but without success. Maybe the standard procedures that worked with Angular 8, are not working with Angular 9.
Try updating your base-href, for example you can update your run script with:
ng build --prod --base-href /production/
or update it dynamically in your server.js/ts when serving the html, do something like
.....server html string generated....
html = html.replace('<base href="/', '<base href="/production/');
package.json Angular6:
{
"name": "adnanrealestate",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#agm/core": "^1.0.0-beta.3",
"#angular-mdc/web": "^0.36.3",
"#angular/animation": "^4.0.0-beta.8",
"#angular/animations": "^6.0.7",
"#angular/cdk": "github:angular/cdk-builds",
"#angular/common": "^6.0.7",
"#angular/compiler": "^6.0.7",
"#angular/core": "^6.0.7",
"#angular/forms": "^6.0.7",
"#angular/http": "^6.0.7",
"#angular/material": "github:angular/material2-builds",
"#angular/platform-browser": "^6.0.7",
"#angular/platform-browser-dynamic": "^6.0.7",
"#angular/platform-server": "^6.1.7",
"#angular/router": "^6.0.7",
"#google-cloud/firestore": "^0.16.1",
"#ng-bootstrap/ng-bootstrap": "^2.1.2",
"#ng-bootstrap/schematics": "^2.0.0-alpha.1",
"#ngrx/store": "^2.2.3",
"#ngui/map": "^0.30.3",
"#ngx-translate/core": "^10.0.2",
"#ngx-translate/http-loader": "^3.0.1",
"#types/googlemaps": "^3.30.10",
"angular-captcha": "^3.4.0",
"angular-file-upload": "^2.5.0",
"angular-file-uploader": "^4.1.1",
"angular-font-awesome": "^3.1.2",
"angularfire2": "^5.0.0-rc.12-next",
"bootstrap": "^4.1.1",
"core-js": "^2.5.4",
"file-saver": "^1.3.8",
"filepond": "^1.8.6",
"firebase": "^5.2.0",
"firebase-admin": "^5.12.1",
"firebase-functions": "^1.1.0",
"firestore": "^1.1.6",
"font-awesome": "^4.7.0",
"fs": "0.0.1-security",
"hammerjs": "^2.0.8",
"json2typescript": "^1.0.6",
"linq2fire": "^1.0.18",
"ng-bootstrap-form-validation": "^3.0.3",
"ng-recaptcha": "^4.0.0",
"ng-slideshow": "^0.8.2",
"ngx-bootstrap": "^3.0.1",
"ngx-gallery": "^5.6.2",
"ngx-international-phone-number": "^0.1.3",
"ngx-intl-tel-input": "^1.0.6",
"ngx-order-pipe": "^2.0.1",
"ngx-pagination": "^3.2.0",
"ngx-popover": "0.0.16",
"rxjs": "^6.0.0",
"rxjs-compat": "^6.2.1",
"time-ago-pipe": "^1.3.2",
"uikit": "^3.0.0-rc.6",
"zone.js": "^0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.6.8",
"#angular/cli": "^6.2.1",
"#angular/compiler-cli": "^6.0.7",
"#angular/language-service": "^6.0.7",
"#types/hammerjs": "^2.0.35",
"#types/jasmine": "~2.8.6",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "^5.0.1",
"tslint": "~5.9.1",
"typescript": "~2.7.2"
}
package.json firebase-functions
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.5"
},
"devDependencies": {
"tslint": "~5.8.0",
"typescript": "~2.8.3"
},
"private": true
}
\%RESOURCE_DIR%\ image
How can I fix this error?
and after a change to $ same error
I use npm install for angular 6 and for firebase functions, I didn't see any difference.
please help this is a bad error I don't know where is error specifically of version or other.
https://github.com/firebase/firebase-tools/issues/610
I solved this problem, It's very easy. You don't need to uninstall.
Step1: open firebase.json
you will show this JSON file
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
Step2: Delete "npm --prefix \"$RESOURCE_DIR\" run lint", and "npm --prefix \"$RESOURCE_DIR\" run build"
"functions": {
"predeploy": [
]
}
Step3: firebase deploy --only functions.
Step4: Like and share my solved.
I need to not allow tslint to fix found errors. For example, if it found comma missing, I need it to only tell me that it found it, and not actually fix it.
I found the "--no-fix" parameter in its vue-cli documentation, but it doesn't look like it is working. (I'm using npm run lint, where "lint": "vue-cli-service lint --no-fix" in package.json)
Are there any other ways to stop tslint's automatic fixes?
The "--no-fix" option works for me. Below is my configuration, please check your lint version:
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 3000",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint --no-fix",
"test:e2e": "vue-cli-service test:e2e",
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"#riophae/vue-treeselect": "0.0.37",
"axios": "^0.18.0",
"bootstrap-vue": "^2.0.0-rc.11",
"izitoast": "^1.4.0",
"moment": "^2.22.2",
"v-calendar": "^0.9.7",
"v-select2-component": "^0.3.1",
"vue": "^2.5.17",
"vue-full-calendar": "^2.7.0",
"vue-izitoast": "^1.1.2",
"vue-js-modal": "^1.3.27",
"vue-router": "^3.0.1",
"vue2-daterange-picker": "^0.1.5",
"vuejs-datepicker": "^1.5.4",
"vuex": "^3.0.1"
},
"devDependencies": {
"#vue/cli-plugin-babel": "^3.1.1",
"#vue/cli-plugin-eslint": "^3.1.5",
"#vue/cli-plugin-unit-jest": "^3.1.1",
"#vue/cli-service": "^3.1.4",
"#vue/eslint-config-standard": "^4.0.0",
"#vue/test-utils": "^1.0.0-beta.20",
"ajv": "^6.5.5",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"eslint": "^5.8.0",
"eslint-plugin-cypress": "^2.1.3",
"eslint-plugin-vue": "^5.0.0-0",
"node-sass": "^4.10.0",
"sass-loader": "^7.1.0",
"vue-template-compiler": "^2.5.17"
}
}
When you have changes and you save it, terminal loads and says
webpack: Compiled successfully.
But lately in my VSC, it doesn't load automatically anymore. I still have to Command C and ng serve a project again and again to see changes on the localhost
package.json
{
"name": "gms",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"sw": "sw-precache --root=dist --config=sw-precache-config.js",
"static-serve": "cd dist && live-server --port=4200 --host=localhost --entry-file=/index.html"
},
"private": true,
"dependencies": {
"#angular/common": "^4.0.0",
"#angular/compiler": "^4.0.0",
"#angular/core": "^4.0.0",
"#angular/forms": "^4.0.0",
"#angular/http": "^4.0.0",
"#angular/platform-browser": "^4.0.0",
"#angular/platform-browser-dynamic": "^4.0.0",
"#angular/router": "^4.0.0",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"ng2-validation": "^4.2.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"#angular/cli": "1.0.0",
"#angular/compiler-cli": "^4.0.0",
"#types/jasmine": "2.5.38",
"#types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.0",
"sw-precache": "^5.1.1",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
I am trying to deploy a MEAN app to Heroku, but cannot push due to the following error:
! No default language could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
See https://devcenter.heroku.com/articles/buildpacks
! Push failed
I tried setting a node.js buildpack with their latest node buildpack release, but just received another error:
failed to detect buildpack
This is my first deployment to Heroku, so I'm brand new at this.
Here are my package.jsons:
Server
{
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"bcrypt": "^1.0.2",
"body-parser": "^1.16.1",
"cookie-parser": "^1.4.3",
"cors": "^2.8.2",
"debug": "^2.6.3",
"ejs": "~2.5.5",
"express": "^4.14.1",
"jsonwebtoken": "^7.3.0",
"mongoose": "^4.9.2",
"morgan": "^1.7.0",
"multer": "^1.3.0",
"passport": "^0.3.2",
"passport-jwt": "^2.2.1",
"request": "^2.81.0",
"request-promise": "^4.2.0",
"serve-favicon": "^2.3.2"
}
}
Client
{
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "^2.4.0",
"#angular/compiler": "^2.4.0",
"#angular/core": "^2.4.0",
"#angular/forms": "^2.4.0",
"#angular/http": "^2.4.0",
"#angular/platform-browser": "^2.4.0",
"#angular/platform-browser-dynamic": "^2.4.0",
"#angular/router": "^3.4.0",
"#types/googlemaps": "^3.26.8",
"#types/jquery": "^2.0.43",
"#types/lodash": "^4.14.62",
"#types/underscore": "^1.8.0",
"amcharts3-angular2": "github:amcharts/amcharts3-angular2",
"angular2-google-maps": "^0.17.0",
"core-js": "^2.4.1",
"dotenv": "^4.0.0",
"jquery": "^3.2.1",
"lodash": "^4.17.4",
"ng2-google-charts": "^2.1.0",
"rxjs": "^5.1.0",
"tslint": "^4.4.2",
"typescript": "^2.0.10",
"underscore": "^1.8.3",
"zone.js": "^0.7.6"
},
"devDependencies": {
"#angular/cli": "1.0.0-rc.0",
"#angular/compiler-cli": "^2.4.0",
"#types/jasmine": "2.5.38",
"#types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.4.2",
"typescript": "~2.0.0"
}
}
Why is Heroku not detecting Node?
According to the Heroku documentation
To determine how to start your app, Heroku first looks for a Procfile.
If no Procfile exists for a Node.js app, we will attempt to start a
default web process via the start script in your package.json.
So you shouldn't need to set the build pack.
I have two package.jsons, one for client and one for server. I needed to put my server dependencies into the root folder (they were each nested in client and server folders, respectively). Moving it into root made it detectable by heroku. Of course, now I have a new error. :)