webpack-4

How to get terser webpack plugin works properly

╄→гoц情女王★ 提交于 2019-12-04 18:22:00
I am trying to understand how to get terser webpack plugin to work in the most simple possible case. This is my code: src/math.js , exports 2 functions. export const double = (x) => x + x; export const triple = (x) => x + x + x; scr/index.js , imports only double function. import { double } from './math.js'; console.log(double(10)); I understood from webpack documentation that I must use ModuleConcatenationPlugin if I want activate tree shaking. This is my webpack config: webpack/index.js const webpack = require('webpack'); const TerserPlugin = require('terser-webpack-plugin'); module.exports

Webpack with sourcemap can't resolve variables in production mode

◇◆丶佛笑我妖孽 提交于 2019-12-04 13:43:09
I would like to generate source maps for our production build with Webpack. I managed to generate it, but when I stop on a breakpoint in the debugger, variables are not resolved: What am I doing wrong? How can I generate a source map that lets the chrome devtools resolve the variables once I stopped on a breakpoint in the debugger? These are my webpack configurations: webpack.config.js : const path = require('path'); const ROOT = path.resolve( __dirname, 'src/main/resources/packedbundle' ); const HtmlWebpackPlugin = require('html-webpack-plugin'); const LoaderOptionsPlugin = require('webpack

React-Loadable SSR with Webpack 4 and Babel 7

醉酒当歌 提交于 2019-12-04 13:11:56
问题 Does server-side rendering with react-loadable work with Webpack 4 and Babel 7? I've been unable to get it working successfully while following the instructions. After following just the client-side steps, Webpack correctly outputs separate chunks for each loadable component and this is reflected when I load the page in the browser (ie: the chunks are lazy-loaded). After following all the SSR steps, however, the server throws the following error: Error: Not supported at loader (/Projects/test

webpack 4 disable uglifyjs-webpack-plugin

对着背影说爱祢 提交于 2019-12-04 10:31:01
问题 I have had this problem for the last 2 days. So I decided to completely disable uglifyjs-webpack-plugin from webpack build process. I was not able to find anything on webpack 4. 回答1: module.exports = { optimization:{ minimize: false, // <---- disables uglify. // minimizer: [new UglifyJsPlugin()] if you want to customize it. } } 来源: https://stackoverflow.com/questions/51263506/webpack-4-disable-uglifyjs-webpack-plugin

Webpack 4 - How to configure minimize?

蹲街弑〆低调 提交于 2019-12-04 07:28:33
问题 Webpack 4 comes with the following statement: webpack.optimize.UglifyJsPlugin has been removed, please use config.optimization.minimize instead. Fair enough, but I cannot find any information about configuring the UglifyJsPlugin instance running under the hood, for example to change the cache directory. Can this be done? 回答1: It's not possible to modify the default configuration. You can use the optimization.minimizer setting to instantiate your own UglifyJsPlugin , however. Using 4.0 we used

Webpack 4: mini-css-extract-plugin + file-loader not loading assets

隐身守侯 提交于 2019-12-04 05:05:52
I'm trying to move assets (images and fonts) used in one of my .scss files, but it seems that they get ignored: This is my .scss file: @font-face { font-family: 'myfont'; src: url('../../assets/fonts/myfont.ttf') format('truetype'); font-weight: 600; font-style: normal; } body { color: red; font-family: 'myfont'; background: url('../../assets/images/bg.jpg'); } And this is my webpack.config.js : const path = require('path'); const { CheckerPlugin } = require('awesome-typescript-loader'); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); module.exports = { target: 'node', entry:

SSR: dynamic import in react app how to deal with html miss match when component is loading on the client

梦想与她 提交于 2019-12-04 04:21:17
问题 I'm just starting on server side rendering a react 16 app using code splitting and dynamic import thanks to webpack 4 and react-loadable. My question might sound stupid but there's something I don't quite get. On the server side, I'm waiting that webpack has loaded all modules before spitting out the html to the client. On the client side I have a kind of loading component rendered, before rendering the loaded component. So basically the server renders the loaded component: <div>loaded

Webpack 4, Vue using Typescript classes and JS code at the same time.

浪子不回头ぞ 提交于 2019-12-04 04:20:17
问题 I am migrating JS files to Typescript and my goal is, to be able to use both JS and Typescript classes in Vue. I know, I can convert Vue scripts into Typescript, but I don't want to do it right now. The problem arises in a component.vue file: this.exceptionHandler = app.resolve('ExceptionHandler'); The errror I get in the browser's console is this (compilation is ok): "TypeError: Cannot call a class as a function" ExceptionHandler is defined in a TypeScript .ts file. The question is: Is it

React-Loadable SSR with Webpack 4 and Babel 7

大城市里の小女人 提交于 2019-12-03 08:21:32
Does server-side rendering with react-loadable work with Webpack 4 and Babel 7? I've been unable to get it working successfully while following the instructions . After following just the client-side steps, Webpack correctly outputs separate chunks for each loadable component and this is reflected when I load the page in the browser (ie: the chunks are lazy-loaded). After following all the SSR steps, however, the server throws the following error: Error: Not supported at loader (/Projects/test-project/web/routes/index.js:50:15) at load (/Projects/test-project/web/node_modules/react-loadable

webpack 4 disable uglifyjs-webpack-plugin

这一生的挚爱 提交于 2019-12-03 06:07:44
I have had this problem for the last 2 days. So I decided to completely disable uglifyjs-webpack-plugin from webpack build process. I was not able to find anything on webpack 4. module.exports = { optimization:{ minimize: false, // <---- disables uglify. // minimizer: [new UglifyJsPlugin()] if you want to customize it. } } 来源: https://stackoverflow.com/questions/51263506/webpack-4-disable-uglifyjs-webpack-plugin