NodeJs: Difference between revisions
Jump to navigation
Jump to search
Line 12: | Line 12: | ||
The run-p runs multiple jobs, pre<value> runs the command before the value without pre | The run-p runs multiple jobs, pre<value> runs the command before the value without pre | ||
= Adding consts in webpack = | |||
To pass dev/production consts we can do this using webpack. Include webpack in you webpack.config.dev.js and webpack.DefinePlugin e.g. | |||
<syntaxhighlight lang="json"> | |||
const webpack = require("webpack") | |||
... | |||
plugins: [ | |||
new webpack.DefinePlugin({ | |||
"process.env.API_URL": JSON.stringify("http:://localhost:3001") | |||
}) | |||
], | |||
... | |||
</syntaxhighlight> |
Revision as of 00:25, 8 June 2020
Setup
Running start up scripts in node
"scripts": {
"start": "run-p start:dev start:api",
"start:dev: "webpack-dev-server --config webpack.config.dev.js --port 3000",
"prestart:api": "node tools/createMockDb.js",
"start:api": "node tools/apiServer.js"
};
The run-p runs multiple jobs, pre<value> runs the command before the value without pre
Adding consts in webpack
To pass dev/production consts we can do this using webpack. Include webpack in you webpack.config.dev.js and webpack.DefinePlugin e.g.
const webpack = require("webpack")
...
plugins: [
new webpack.DefinePlugin({
"process.env.API_URL": JSON.stringify("http:://localhost:3001")
})
],
...