Last active
May 2, 2018 12:23
-
-
Save olehmelnyk/a87225493b26a63bd1f4ef1efef4a367 to your computer and use it in GitHub Desktop.
Webpack - Open Chrome w/ dev env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const webpack = require('webpack'); | |
const htmlWebpackPlugin = require('html-webpack-plugin'); | |
const browserPlugin = require('webpack-browser-plugin'); | |
const chromeUserDataDir = `C:\\Chrome dev session`; | |
module.exports = { | |
context: path.resolve(__dirname, 'src'), | |
entry: './index.js', | |
output: { | |
filename: 'bundle.js', | |
path: path.resolve(__dirname, 'dist') | |
}, | |
resolve: { | |
extensions: ['.js', '.ts'] | |
}, | |
watch: true, | |
plugins: [ | |
new htmlWebpackPlugin({ | |
hash: true, | |
minify: { | |
html5: true, | |
minifyCSS: true, | |
minifyJS: true | |
}, | |
template: './template.html' | |
}), | |
new webpack.HotModuleReplacementPlugin(), | |
new browserPlugin({ | |
openOptions: { | |
app: [ | |
'chrome', | |
// All Chrome startup flags here - https://peter.sh/experiments/chromium-command-line-switches/ | |
//'--kiosk', // run in full-screen without browser UI - Alt+F4 to exit | |
//'--incognito', | |
//'--start-fullscreen', | |
'--auto-open-devtools-for-tabs', | |
'--disable-web-security', // to enable CORS | |
'--allow-cross-origin-auth-prompt', | |
'--user-data-dir=' + path.resolve(chromeUserDataDir) // to let Chrome create 'new user' (like fresh install) and store here all dev plugins, settings, etc. | |
] | |
} | |
}) | |
], | |
devServer: { | |
hot: true, | |
headers: { | |
'Access-Control-Allow-Origin': '*', | |
'Access-Control-Allow-Credentials': true, | |
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS', | |
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization' | |
} | |
}, | |
devtool: 'eval' | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment