I am following loopback environment specific configuration to refer environment specific config, data sources and middleware json files.
When I push my app to a staging server, NODE_ENV environment variable gets set to staging and based on this variable config.staging.json and datasources.staging.json files are referred but NOT middleware.staging.json.
Here is the complete content of middleware.json file:
{
"initial:before": {
"loopback#favicon": {}
},
"initial": {
"compression": {},
"cors": {
"params": {
"origin": true,
"credentials": true,
"maxAge": 86400
}
}
},
"session": {},
"auth": {},
"parse": {},
"routes": {},
"files": {
"loopback#static": [
{
"params": "$!../client/WebApp/www"
}
]
},
"final": {
"loopback#urlNotFound": {}
},
"final:after": {
"errorhandler": {}
}
}
and I would like to refer middleware.staging.json file whose complete content is:
{
"files": {
"loopback#static": [
{
"params": "$!../client/WebApp/dist"
}
]
}
}
I am trying to change the target folder from www to dist. It seems middleware.staging.json file is not referred and middleware.json file is always referred irrespective of NODE_ENV variable.
Am I creating environment specific middleware file correctly? Any alternates to achieve this?
Related
In cypress.json file i have the following code
{
"baseUrl": "test",
"ignoreTestFiles": [],
"viewportHeight": 768,
"viewportWidth": 1024,
"video": false,
"env": { "email": "test#email.com", "password": "password" }
}
When i am trying to access it by calling Cypress.env('password') it shows undefined in console log when printing it, what is the issues.
const password: string = Cypress.env('password')
describe("Login to the application", () => {
beforeEach(() => {
cy.visit("/");
});
it.only("user should login successfully", () => {
console.log(Cypress.env('email')). --- undefined
loginPage.login(email, password);
cy.url().should("include", "/wallet");
});
My mistake for not knowing or not checking the location of my cypress.json file, moved it to the top cypress folder and value is shown properly.
In my Projekt (Version 10.xx) the cypress.config.ts must be in the root path not in the cypress folder. You can generate the config with the UI, to get it on the right location:
Settings > Project settings > cypress.config.ts
UPDATE for CYPRESS V10.
Extending #Artjom Prozorov answer,
Now in the newer version the cypress.json naming convention is deprecated.
So, we have to use cypress.config.ts as file name for configuration.
sample of file content given below.
import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
specPattern: "src/**/*.cy.{js,jsx,ts,tsx}",
baseUrl: "http://localhost:3001",
trashAssetsBeforeRuns: false,
viewportWidth:1920,
viewportHeight:1080,
slowTestThreshold: 1000,
// watchForFileChanges : false,
env: {
apiUrl : "http://localhost:3000",
commandDelay: 100,
password: 'here it is'
},
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'cypress/reports',
overwrite: false,
html: true,
json: false
},
setupNodeEvents(on, config) {
config.env.sharedSecret =
process.env.NODE_ENV === 'development' ? 'itsDev' : 'itsLocal'
return config
}
},
component: {
devServer: {
framework: "create-react-app",
bundler: "webpack"
}
}
});
NOTE : this cypress.config.ts must be inside the cypress directory.
I have to use a non open source pub/sub library for websockets (diffusion) and have to stick to a specific version because it's what is used on the server side and I have no control about it.
The issue is that in one single util in their code base they use the reserved keyword interface and that triggers a minification error that breaks the build:
Failed to minify the code from this file:
./node_modules/babel-loader/lib??ref--6-oneOf-2!./node_modules/diffusion/src/node_modules/util/interface.js:127
Read more here: bit.ly/CRA-build-minify
Which regex can I use to exclude this dependency from minification?
config.optimization.minimizer[0].options.exclude = /node_modules/; does not ecxlude it from minification.
config.optimization.minimizer[0].options.exclude = /^.*(node_modules|.js).*$/; works but it's too broad
For more context, this is the code of the dependency that is causing the minification to fail:
node_modules/diffusion/src/node_modules/util/interface.js
function _implements() {
var args = Array.prototype.slice.call(arguments, 0);
var impl = args.pop();
var unsatisfied = [];
...
// The joys of duck type. Quack quack
args.forEach(function(interface) { <<<<<<<<<<<<<<<<<<<<<
unsatisfied = unsatisfied.concat(interface(impl));
});
This is how the webpack config file looks like before my overrides: (we are not allowed to eject)
"optimization": {
"minimizer": [
{
"options": {
"test": {
},
"extractComments": false,
"sourceMap": true,
"cache": true,
"parallel": true,
"terserOptions": {
"output": {
"ecma": 5,
"comments": false,
"ascii_only": true
},
"parse": {
"ecma": 8
},
"compress": {
"ecma": 5,
"warnings": false,
"comparisons": false,
"inline": 2
},
"mangle": {
"safari10": true
}
}
}
},
{
"pluginDescriptor": {
"name": "OptimizeCssAssetsWebpackPlugin"
},
"options": {
"assetProcessors": [
{
"phase": "compilation.optimize-chunk-assets",
"regExp": {
}
}
],
This has been fixed as of version 6.0.0
It's easier to fix when not ejecting IMO.
You're probably using old version or react-scripts, just upgrade it to react-scripts#>=2.0.0.
Taken from this section of React Documentation
We wrote a custom library that we now want to reference in our main application.
Thus we added the following two entries to the consumer's neo-app.json:
{
"path": "/webapp/resources/some/lib",
"target": {
"type": "application",
"name": "somedemolib"
},
"description": "..."
}, {
"path": "/resources/some/lib",
"target": {
"type": "application",
"name": "somedemolib"
},
"description": "..."
}
and the following to the manifest.json of the libs consumer:
"dependencies": {
"minUI5Version": "1.30.0",
"libs": {
...
"some.lib": {
"minVersion": "1.0.0"
}
}
},
However upon loading the web-app I can see a HTTP404 when trying to load the library under the following path:
Uncaught Error: failed to load 'some/lib/library.js' from ../../resources/some/lib/library.js: 404 - Not Found
You have to declare your custom scripts in the first lines of your components.js
First of all you have to declare the path of your custom lib folder:
https://sapui5.netweaver.ondemand.com/sdk/docs/api/symbols/jQuery.sap.html#.registerModulePath
jQuery.sap.registerResourcePath("libs/custom", "/scripts/customlibs");
After that call you are able to load your script from that path with this call:
jQuery.sap.require("libs.custom.nameofyourscript");
"libs.custom" points to that folder you have registered previously and then your are able to import the script by its name. So your components.js looks like this:
jQuery.sap.registerResourcePath("libs/custom", "/scripts/customlibs");
jQuery.sap.require("libs.custom.nameofyourscript");
// Now the declaration of the components starts
sap.ui.core.UIComponent.extend("yourappname.Component", {
// ...
I am trying to understand the below content in config.js file created by jspm install. I have followed the Config api but could not make out much with the description that is there. Looking at the folders created and packages installed .. looks like there is some kind of relation between paths and map options.
System.config({
baseURL: "/",
defaultJSExtensions: true,
transpiler: "typescript",
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: {
"typescript": "npm:typescript#1.6.0-dev.20150825",
"github:jspm/nodelibs-buffer#0.1.0": {
"buffer": "npm:buffer#3.4.3"
},
"github:jspm/nodelibs-os#0.1.0": {
"os-browserify": "npm:os-browserify#0.1.2"
},
"github:jspm/nodelibs-path#0.1.0": {
"path-browserify": "npm:path-browserify#0.0.0"
},
"github:jspm/nodelibs-process#0.1.1": {
"process": "npm:process#0.10.1"
},
"npm:buffer#3.4.3": {
"base64-js": "npm:base64-js#0.0.8",
"ieee754": "npm:ieee754#1.1.6",
"is-array": "npm:is-array#1.0.1"
},
"npm:os-browserify#0.1.2": {
"os": "github:jspm/nodelibs-os#0.1.0"
},
"npm:path-browserify#0.0.0": {
"process": "github:jspm/nodelibs-process#0.1.1"
},
"npm:typescript#1.6.0-dev.20150825": {
"buffer": "github:jspm/nodelibs-buffer#0.1.0",
"child_process": "github:jspm/nodelibs-child_process#0.1.0",
"fs": "github:jspm/nodelibs-fs#0.1.2",
"os": "github:jspm/nodelibs-os#0.1.0",
"path": "github:jspm/nodelibs-path#0.1.0",
"process": "github:jspm/nodelibs-process#0.1.1",
"readline": "github:jspm/nodelibs-readline#0.1.0"
}
}
});
Can some body help me out with understanding the config? Please bear with me .. I am a beginner trying to understand the javascript ecosystem.
Thanks!
This is an old question but I will answer anyway if someone else runs into here.
Let's say the script runs into this definition within map:
github:jspm/nodelibs-buffer#0.1.0
The parser will go and and check github:* entry in paths and replace it with the value jspm_packages/github/* there (like regex), and resulting with:
jspm_packages/github/jspm/nodelibs-buffer#0.1.0
When loading files and etc, System.js will be able to find where scripts are installed with this information.
I want to set up a Grunt task to run JSDoc. I am using grunt-jsdoc which the JSDoc npm page recommends. It works ok, but I cannot use my jsdoc.json file I have created.
{
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc","closure"]
},
"source": {
"include": [
"lib/",
"routes/",
"README.md"
]
},
"plugins": ["plugins/markdown"],
"templates": {
"cleverLinks": false,
"monospaceLinks": false
},
"opts": {
"destination": "public/docs"
}
}
I have found that when I pull bits out of the JSDoc and put them in Grunt, I have no issues:
//This will generate a blank public/docs folder
jsdoc: {
dist : {
src: './jsdoc.json'
options: {
destination: 'public/docs'
}
}
}
I want to be able to just reference the JSON file, and have it work. Currently, doing this will not generate errors, but it doesn't do anything other then creating an empty doc folder in the base directory.
jsdoc: {
dist : {
src: './jsdoc.json'
}
}
I have also verified that the jsdoc.json file is correct jsdoc -c jsdoc.json
You need to put the conf file into the options property.
jsdoc: {
dist: {
options: {
configure: './jsdoc.json'
}
}
}