How to Polyfill node core modules in webpack 5

I was also getting these error’s when upgrading from webpack v4 to v5. Resolved by making the following changes to webpack.config.js added resolve.fallback property removed node property { resolve: { modules: […], fallback: { “fs”: false, “tls”: false, “net”: false, “path”: false, “zlib”: false, “http”: false, “https”: false, “stream”: false, “crypto”: false, “crypto-browserify”: require.resolve(‘crypto-browserify’), //if … Read more

I am getting an “Invalid Host header” message when connecting to webpack-dev-server remotely

The problem occurs because webpack-dev-server 2.4.4 adds a host check. You can disable it by adding this to your webpack config: devServer: { compress: true, disableHostCheck: true, // That solved it } Please note, this fix is insecure. Please see this answer for a secure solution. The option was refactored in version 4.0.0. The allowedHosts … Read more

How to build minified and uncompressed bundle with webpack?

webpack.config.js: const webpack = require(“webpack”); module.exports = { entry: { “bundle”: “./entry.js”, “bundle.min”: “./entry.js”, }, devtool: “source-map”, output: { path: “./dist”, filename: “[name].js” }, plugins: [ new webpack.optimize.UglifyJsPlugin({ include: /\.min\.js$/, minimize: true }) ] }; Since Webpack 4, webpack.optimize.UglifyJsPlugin has been deprecated and its use results in error: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize … Read more

The create-react-app imports restriction outside of src directory

This is special restriction added by developers of create-react-app. It is implemented in ModuleScopePlugin to ensure files reside in src/. That plugin ensures that relative imports from app’s source directory don’t reach outside of it. There is no official way to disable this feature except using eject and modify webpack config. But, most features and … Read more

Webpack style-loader vs css-loader

The CSS loader takes a CSS file and returns the CSS with imports and url(…) resolved via webpack’s require functionality: var css = require(“css!./file.css”); // => returns css code from file.css, resolves imports and url(…) It doesn’t actually do anything with the returned CSS. The style loader takes CSS and actually inserts it into the … Read more

What does “publicPath” in Webpack do?

output.path Local disk directory to store all your output files (Absolute path). Example: path.join(__dirname, “build/”) Webpack will output everything into localdisk/path-to-your-project/build/ output.publicPath Where you uploaded your bundled files. (absolute path, or relative to main HTML file) Example: /assets/ Assumed you deployed the app at server root http://server/. By using /assets/, the app will find webpack … Read more

What exactly is Hot Module Replacement in Webpack?

First I want to note that Hot Module Replacement (HMR) is still an experimental feature. HMR is a way of exchanging modules in a running application (and adding/removing modules). You basically can update changed modules without a full page reload. Documentation Prerequirements: Using Plugins: https://webpack.js.org/concepts/plugins/ Code Splitting: https://webpack.js.org/guides/code-splitting/ webpack-dev-server: https://webpack.js.org/configuration/dev-server/ It’s not so much for … Read more

How to add font-awesome to Angular 2 + CLI project

After Angular 2.0 final release, the structure of the Angular2 CLI project has been changed — you don’t need any vendor files, no system.js — only webpack. So you do: npm install font-awesome –save In the angular-cli.json file locate the styles[] array and add font-awesome references directory here, like below: “apps”: [ { “root”: “src”, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)