webpack-4

How to use Webpack 4 to compile Sass files properly?

笑着哭i 提交于 2019-12-13 20:26:30
问题 My code is working but it ends up with unnecessary .js files in the output directory. I'm trying to find a way to get a clean output. To make it clear what I mean I describe my code below: You can find my project here. The Webpack config is the following (tasks/options/webpack.js, I'm using grunt to run webpack if it matters): const path = require('path'); const webpack = require('webpack'); const autoprefixer = require('autoprefixer'); const MiniCssExtractPlugin = require('mini-css-extract

How webpack 4 code splitting work? Is there a hidden code which makes a http request for next chunk?

China☆狼群 提交于 2019-12-13 18:11:55
问题 I am trying to understand how Webpack 4 code splitting works under the hood. Is there a hidden code which makes a http request for next chunk? Follow up question: If I split code between login.js(login page) and app.js(actual app), is it possible to intercept the call from login.js for next chunk and based on successful authentication or not, serve app.js if successful or serve error.js on failed authentication? 回答1: Webpack v4 has latest upgrades. Previously if we do code splitting, You can

Aliasing with Webpack 4 and awesome-typescript loader not working

久未见 提交于 2019-12-13 12:25:22
问题 I'm currently having issue getting aliasing to work properly. From my understanding, to get aliasing to work properly with webpack you have to: Versions "typescript": "2.8.3", "webpack": "4.16.2", "webpack-cli": "3.1.0", "awesome-typescript-loader": "5.2.0", "html-webpack-plugin": "3.2.0", "source-map-loader": "^0.2.3", define the alias in tsconfig as paths. I verified that my tsconfig and paths/aliasing is correct by building it. If it wasn't configured correctly, it would have failed the

laravel-mix configuration for vue-loader

房东的猫 提交于 2019-12-13 03:45:04
问题 I was trying to create a css modules using vuejs. However, I cannot figure out how to configure the webpack. Here is my Vue component <template> <div> <div :class="$style.header_top"> </div> </div> </template> <style module lang="scss"> $black: #1e1e1e; $white: #fff; .header { position: absolute; width: 100%; &_top { background-color: $black; padding: 15px 0; } .... </style> This is my laravel-mix configuration: mix.webpackConfig({ module: { rules: [ { test: /\.css$/, resourceQuery: '/module/

How to forbid replacing process.env variables during compilation in webpack?

狂风中的少年 提交于 2019-12-12 12:24:09
问题 Story I'm developing the AWS Lambda functions and compile the code using webpack . I've read some of the articles and it seems that the process.env variables are auto replaced during compilation. Although it's cool I want to forbid this behaviour. Why? Because I'm passing environment variables using AWS Lambda dashboard. Webpack configuration const nodeExternals = require('webpack-node-externals') const webpack = require('webpack') const path = require('path') module.exports = { target: 'node

How to get terser webpack plugin works properly

夙愿已清 提交于 2019-12-12 09:13:15
问题 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

How to update default react(CRA) to webpack4 and babel7?

本小妞迷上赌 提交于 2019-12-11 21:31:49
问题 If someone has done it, please help me with updating dependencies and webpack configuration file. 回答1: You will either need to eject and update configs yourself or wait for CRA v2 to be released which tackles both these issues. More context here: https://github.com/facebook/create-react-app/issues/3815 react-scripts is what abstracts and powers tooling like webpack and babel 来源: https://stackoverflow.com/questions/52466801/how-to-update-default-reactcra-to-webpack4-and-babel7

Gulp4 watch no reaction to changes

℡╲_俬逩灬. 提交于 2019-12-11 19:37:52
问题 Migrating to Gulp 4 I encountered serious issues: no reaction to changes when using gulp.watch or gulp-watch. import gulp from 'gulp'; // import {get as browserSync} from 'browser-sync'; import watch from 'gulp-watch'; // const bs = browserSync('server'); var bSync = require('browser-sync').create(); gulp.task('browser-sync', function() { bSync.init({ server: { baseDir: "../" }, notify: true }); }); gulp.task('watch', gulp.parallel('browser-sync', ()=> { global.watch = true; gulp.watch('app/

react-router-dom BrowserRouter not navigating to paths with more than one url parameter

微笑、不失礼 提交于 2019-12-11 16:46:20
问题 I am having an issue where I am not able to navigate to Routes with paths greater than 1 section like so when using react-router-dom@4.2.2 : In addition, this is the Github link to the repo where I am having this issue. https://github.com/ShawnCholeva/React-Typescript-Webpack4-Router import React, { Component } from 'react'; import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; //All routes work if I use HashRouter here instead of BrowserRouter class App extends Component

webpack 4 images in node_modules : module not found

岁酱吖の 提交于 2019-12-11 10:45:01
问题 The problem Im using webpack 4 to compile scss to css and MiniCssExtractPlugin to save the css into a different file. The problem is, that i dont manage to load images and fonts, that are included via url() inside of the scss files. It also makes no difference between running development or production. Scss is compiled perfectly and without any problems. Also the scss-loader has no problems loading .scss-files from node_modules. Why does this error occur and how can i fix it? error-message