Set dynamically aboslute public path on 'npm run watch'; fix http/htt… (#1696)
* Set dynamically aboslute public path on 'npm run watch'; fix http/https hardcoded in watch.js * WEBPACK_PUBLIC_PATH fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"entry": {
|
"entry": {
|
||||||
"main": [
|
"main": [
|
||||||
|
"./scripts/util/public-path.js",
|
||||||
"./scripts/main.js",
|
"./scripts/main.js",
|
||||||
"./styles/main.scss"
|
"./styles/main.scss"
|
||||||
],
|
],
|
||||||
|
|||||||
8
assets/scripts/util/public-path.js
Normal file
8
assets/scripts/util/public-path.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
/* globals WEBPACK_PUBLIC_PATH */
|
||||||
|
|
||||||
|
// Dynamically set absolute public path from current protocol and host
|
||||||
|
if (WEBPACK_PUBLIC_PATH !== false) {
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
__webpack_public_path__ = location.protocol + '//' + location.host + WEBPACK_PUBLIC_PATH;
|
||||||
|
/*eslint-enable no-undef*/
|
||||||
|
}
|
||||||
8
watch.js
8
watch.js
@@ -9,15 +9,9 @@ var webpackConfig = require('./webpack.config'),
|
|||||||
config = require('./assets/config');
|
config = require('./assets/config');
|
||||||
|
|
||||||
// Internal variables
|
// Internal variables
|
||||||
var host = 'http://localhost',
|
var compiler = webpack(webpackConfig);
|
||||||
port = config.devPort || '3000',
|
|
||||||
compiler;
|
|
||||||
|
|
||||||
webpackConfig.output.publicPath = host + ':' + port + config.output.publicPath;
|
|
||||||
compiler = webpack(webpackConfig);
|
|
||||||
|
|
||||||
browserSync.init({
|
browserSync.init({
|
||||||
port: port,
|
|
||||||
proxy: {
|
proxy: {
|
||||||
target: config.devUrl,
|
target: config.devUrl,
|
||||||
middleware: [
|
middleware: [
|
||||||
|
|||||||
@@ -191,6 +191,9 @@ webpackConfig = {
|
|||||||
'window.jQuery': 'jquery',
|
'window.jQuery': 'jquery',
|
||||||
'Tether': 'tether',
|
'Tether': 'tether',
|
||||||
'window.Tether': 'tether'
|
'window.Tether': 'tether'
|
||||||
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
WEBPACK_PUBLIC_PATH: (argv.watch === true) ? JSON.stringify(path.join(config.publicPath, dist)) : false
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
postcss: [
|
postcss: [
|
||||||
|
|||||||
Reference in New Issue
Block a user