Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

webpack-dev-server running

npx webpack serve
Comment

webpack dev server

 devServer: {
    contentBase: path.join(__dirname, 'dist'),
    compress: true,
    port: 9000,
  },
 // on package json file..
 "start": "./node_modules/.bin/webpack serve",
Comment

webpack dev server

// TIPS AND TRICK CUSTOM PROXY IN WEBPACK DEV SERVER BY restuwahyu13
//NOTE this method like using CRA in React

// manual proxy before
module.exports = {
	devServer: {
		open: true,
		compress: true,
		hot: true,
		inline: true,
		lazy: true,
		contentBase: resolve(process.cwd(), 'build'),
		port: process.env.PORT || 3000,
		proxy: {
          '/api/*', {
          	target: 'http://localhost:3001',
			secure: false,
			changeOrigin: true,
			headers: {
				'Access-Control-Allow-Origin': '*',
				'Access-Control-Allow-Credentials': '*',
				'Access-Control-Allow-Methods': '*'
			}
          }
        }
		liveReload: false
	}
}

// custom proxy after
module.exports = {
	devServer: {
		open: true,
		compress: true,
		hot: true,
		inline: true,
		lazy: true,
		contentBase: resolve(process.cwd(), 'build'),
		port: process.env.PORT || 3000,
		before: (app, server, compiler) => {
			const pathProxy = resolve(process.cwd(), 'src/setupProxy')
			return require(`${pathProxy}`)(app)
		},
		liveReload: false
	}
}
Comment

webpack-dev-server --https

webpack serve --https --key ./path/to/server.key --cert ./path/to/server.crt --cacert ./path/to/ca.pem
Comment

PREVIOUS NEXT
Code Example
Javascript :: print js example 
Javascript :: svg clientx 
Javascript :: uiimage from assets 
Javascript :: import and export data in mongodb 
Javascript :: Object Property Shorthand javascript 
Javascript :: add to array applescript 
Javascript :: array.length 
Javascript :: flutter post request 
Javascript :: get value from input by id in angular 
Javascript :: GET and CHANGE the class of an element 
Javascript :: email valid javascript 
Javascript :: angularjs form validation on submit 
Javascript :: setstate 
Javascript :: make shorter if statements with objects 
Javascript :: horizontal tabs in react js 
Javascript :: function create array javascript 
Javascript :: javascript addeventlistener click multiple elements 
Javascript :: get query params from url 
Javascript :: Angular patchValue dynamically 
Javascript :: server smtp 
Javascript :: build react app 
Javascript :: how to add jquery to an html css and javascript project 
Javascript :: react-router in saga 
Javascript :: ajax call to load a page on scrolling 
Javascript :: javascript dom after a element 
Javascript :: upload photos cypress 
Javascript :: update an array element with an array in mongoose 
Javascript :: get all objects from s3 bucket nodejs 
Javascript :: restart bot discord.js 
Javascript :: change value on selected jquery 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =