Last active
March 31, 2018 09:16
-
-
Save sergioska/951155ebd3727d41e03420ad0d41b91c to your computer and use it in GitHub Desktop.
webpack configuration to use dev server without add localhost switch on source
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
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
# redirect every requested real file (.js, .css, ecc ...) to webpack dev server | |
RewriteCond %{REQUEST_FILENAME} -f | |
RewriteRule ^public/assets/(.*)$ http://localhost:3000/assets/$1 [L] | |
</IfModule> |
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
var webpack = require('webpack'); | |
module.exports = function(env) { | |
var config = { | |
entry: { | |
"main": [ | |
// ... source js path | |
] | |
}, | |
output: { | |
path: path.resolve(__dirname, 'web/public'), | |
filename: "assets/js/[name].bundle.js" | |
}, | |
devServer: { | |
contentBase: __dirname + '/web/public', | |
hot: true, | |
inline: true, | |
host: "localhost", | |
port: 3000, | |
headers: { | |
"Access-Control-Allow-Origin": "*", | |
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS", | |
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization" | |
} | |
}, | |
}; | |
config.plugins = [ | |
new webpack.HotModuleReplacementPlugin(), | |
// ... | |
] | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Follow below steps to use WDS (webpack dev server) with apache to serve assets path directly from dev server without add any bad switch code to your sources