itgalaxy / browser-sync-dev-hot-webpack-plugin Goto Github PK
View Code? Open in Web Editor NEWCombines BrowserSync, webpack-dev-middleware, and webpack-hot-middleware into one plugin
License: MIT License
Combines BrowserSync, webpack-dev-middleware, and webpack-hot-middleware into one plugin
License: MIT License
When Browsersync is configured with
ui: false
the server crashes (stack trace at the bottom). I traced the problem to these lines of code in BrowserSyncDevHotWebpackPlugin.js
proxyReq.setHeader('X-Browser-Sync-URL-UI', browserSyncURLUI);
proxyReq.setHeader('X-Browser-Sync-URL-UI-External', browserSyncURLUIExternal);
I've tested it by commenting out the lines and it works. The fix would be to guard them with something like:
if (browserSyncURLUI && browserSyncURLUIExternal ) {
proxyReq.setHeader('X-Browser-Sync-URL-UI', browserSyncURLUI);
proxyReq.setHeader('X-Browser-Sync-URL-UI-External', browserSyncURLUIExternal);
}
It's possible to guard them separately, but I don't think that would make sense.
If you'd like me to do a pull request for you, I will do it, but given the simplicity of the change it might be easier for you to do it yourself.
Here's the stack trace:
Local: http://localhost:3000
External: http://192.168.1.17:3000
----------------------------------
_http_outgoing.js:354
throw new Error('"value" required in setHeader("' + name + '", value)');
^
Error: "value" required in setHeader("X-Browser-Sync-URL-UI", value)
at ClientRequest.OutgoingMessage.setHeader (_http_outgoing.js:354:11)
at merge.all.proxy.proxyReq (/home/mwolf/tools/junk/node_modules/browser-sync-dev-hot-webpack-plugin/src/BrowserSyncDevHotWebpackPlugin.js:57:38)
at /home/mwolf/tools/junk/node_modules/browser-sync/lib/server/proxy-server.js:129:24
at List.__iterate (/home/mwolf/tools/junk/node_modules/immutable/dist/immutable.js:2208:13)
at List.forEach (/home/mwolf/tools/junk/node_modules/immutable/dist/immutable.js:4383:19)
at ProxyServer.<anonymous> (/home/mwolf/tools/junk/node_modules/browser-sync/lib/server/proxy-server.js:127:17)
at ProxyServer.emit (/home/mwolf/tools/junk/node_modules/eventemitter3/index.js:119:35)
at ClientRequest.<anonymous> (/home/mwolf/tools/junk/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:117:27)
at emitOne (events.js:101:20)
at ClientRequest.emit (events.js:188:7)
at tickOnSocket (_http_client.js:574:7)
at onSocketNT (_http_client.js:586:5)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
In option you add callback
property.
But not called here https://github.com/itgalaxy/browser-sync-dev-hot-webpack-plugin/blob/master/src/BrowserSyncDevHotWebpackPlugin.js#L173
This is mistake?
You wanted to write the following:
this.options.callback.call(this, bs)
Update api for use custom plugins:
example:
https://github.com/shakyShane/html-injector
Branch | Build failing 🚨 |
---|---|
Dependency | eslint-plugin-import |
Current Version | 2.3.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As eslint-plugin-import is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 10 commits.
44ca158
update utils changelog
a3728d7
bump eslint-module-utils to v2.1.0
3e29169
bump v2.4.0
ea9c92c
Merge pull request #737 from kevin940726/master
8f9b403
fix typos, enforce type of array of strings in allow option
95315e0
update CHANGELOG.md
28e1623
eslint-module-utils: filePath in parserOptions (#840)
2f690b4
update CI to build on Node 6+7 (#846)
7d41745
write doc, add two more tests
dedfb11
add allow glob for rule no-unassigned-import, fix #671
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
package.json
files, so that was left aloneIf you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
In order to set up HMR on a Prestashop development site, I would like to use your plugin.
When I launch "npm run hot", the browser launches but the terminal remains blocked on"[wdm]: wait until bundle finished: " as long as I do not edit my theme.js file. The browser is trying to load images infinitely.
Once I've modified theme.js, WDM shows "Compiled successfully". The JS is loaded in the browser, but the compiled CSS does not load into the browser. However, it's well compiled each time I edit it.
Here is my webpack.config.js :
const webpack = require('webpack');
const path = require('path');
const autoprefixer = require('autoprefixer');
const TerserPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const BrowserSyncHotPlugin = require('browser-sync-dev-hot-webpack-plugin');
const browserSyncPort = 3000;
const themeFolderName = 'classic-rocket';
const PUBLIC_PATH = http://localhost:${browserSyncPort}/themes/${themeFolderName}/assets/js/
;
const BROWSER_SYNC_OPTIONS = {
open: true,
port: browserSyncPort,
proxy: {
target: 'server url'
},
files: [ // full page reload if .tpl file changed
'../themes//*.tpl',
'../modules//*.tpl'
]
};
const DEV_MIDDLEWARE_OPTIONS = {
publicPath: PUBLIC_PATH,
stats: {
colors: true,
chunck: false
},
hot: true
};
const HOT_MIDDLEWARE_OPTIONS = {};
module.exports = (env, argv) => {
const IS_DEV = argv.mode === "development";
const IS_PROD = argv.mode === "production";
return {
mode: argv.mode,
devtool: IS_DEV ? 'source-map' : '',
entry: {
theme: [
'./js/theme.js',
'./css/theme.scss'
]
},
output: {
path: path.resolve(__dirname, '../assets/js'),
filename: '[name].js',
publicPath: argv.hot ? PUBLIC_PATH : ""
},
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
include: [
path.join(__dirname, '')
],
use: ['babel-loader']
},
{
test: /.s[ac]ss/,
use: [
{loader: MiniCssExtractPlugin.loader},
{
loader: 'css-loader',
options: {
sourceMap: IS_DEV,
minimize: IS_PROD
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: IS_DEV,
plugins: function () {
return [autoprefixer]
}
}
},
{
loader: 'sass-loader',
options: {
sourceMap: IS_DEV
}
},
]
},
{
test: /.(woff(2)?|eot|ttf|svg)(?[a-z0-9=.]+)?$/,
exclude: [/img/],
loader: 'file-loader',
options: {
name: '../fonts/[hash].[ext]'
}
},
{
test: /.(png|jpg|gif|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name: '../img/[hash].[ext]'
}
}
]
},
{
test: /.css$/,
use: [{
loader: 'style-loader',
options: {sourceMap: IS_DEV}
}, {
loader: 'css-loader',
options: {sourceMap: IS_DEV}
}, {
loader: 'postcss-loader',
options: {sourceMap: IS_DEV}
}]
}
]
},
externals: {
prestashop: 'prestashop',
$: '$',
jquery: 'jQuery'
},
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
test: /.js($|?)/i,
sourceMap: IS_DEV,
terserOptions: {
compress: {
booleans: IS_PROD,
conditionals: IS_PROD,
drop_console: IS_PROD,
drop_debugger: IS_PROD,
if_return: IS_PROD,
join_vars: IS_PROD,
keep_classnames: IS_DEV,
keep_fnames: IS_DEV,
reduce_vars: IS_PROD,
sequences: IS_PROD,
warnings: IS_DEV
},
output: {
comments: IS_DEV
}
}
}),
new OptimizeCSSAssetsPlugin({})
]
},
plugins: [
(argv.hot ?
new BrowserSyncHotPlugin({
browserSync: BROWSER_SYNC_OPTIONS,
devMiddleware: DEV_MIDDLEWARE_OPTIONS,
hotMiddleware: HOT_MIDDLEWARE_OPTIONS,
callback() {
console.log('Callback');
/*
// Use browser sync server api (https://browsersync.io/docs/api)
const { watcher: bs } = this;
bs.notify("Hello! It's callback function from BrowserSyncHotPlugin!");
*/
}
})
: false),
new MiniCssExtractPlugin({
filename: "../css/[name].css",
chunkFilename: "../css/[id].css"
}),
new webpack.ProvidePlugin({
Popper: ['popper.js', 'default']
})
].filter(function(plugin) { return plugin !== false; }),
watchOptions: {
ignored: /node_modules/
}
}
}`
Here is my package.json :
{
"name": "prestarocket-dev-tools",
"version": "1.0.0",
"description": "Tools to help while developing the Classic theme",
"main": "index.js",
"scripts": {
"hot": "webpack --mode development --devtool source-map --watch --hot",
"build": "webpack -p",
"start": "webpack -p --watch",
"debug": "webpack --mode development --devtool source-map --watch",
"fulldebug": "webpack --mode development --debug --devtool source-map --output-pathinfo --display-chunks --display-error-details --watch --progress --colors"
},
"author": "Prestarocket",
"license": "AFL-3.0",
"dependencies": {
"@babel/core": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"autoprefixer": "^9.4.4",
"babel-loader": "^8.0.4",
"bootstrap": "4.2.1",
"bootstrap-touchspin": "^4.2.5",
"browser-sync": "^2.26.3",
"css-loader": "^1.0.1",
"exports-loader": "^0.7.0",
"expose-loader": "^0.7.5",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^2.0.0",
"flexibility": "^2.0.1",
"imports-loader": "^0.8.0",
"jquery": "^3.3.1",
"lazysizes": "4.1.5",
"material-design-icons": "^2.1.3",
"mini-css-extract-plugin": "^0.4.5",
"node-sass": "^4.10.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"popper.js": "^1.14.6",
"postcss-flexibility": "^2.0.0",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^1.1.0",
"webpack": "^4.26.1",
"webpack-cli": "^3.1.2",
"webpack-dev-middleware": "^3.5.1",
"webpack-hot-middleware": "^2.24.3"
},
"devDependencies": {
"browser-sync-dev-hot-webpack-plugin": "^0.2.2"
}
}
1.16.1
to 1.16.2
.This version is covered by your current version range and after updating it in your project the build failed.
prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Can you add webpack 4 version in peerDependencies
or change it for something like this >=2.0.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.