Questions tagged [webpack]
Webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it can also transform, bundle, or package just about any resource or asset. Webpack takes modules with dependencies and generates static assets representing those modules. Webpack enables extensibility and promotes best practices in web architecture and performance.
webpack
3,657
questions
144
votes
5
answers
19k
views
Javascript object bracket notation ({ Navigation } =) on left side of assign
I haven't seen this syntax before and am wondering what it's all about.
var { Navigation } = require('react-router');
The brackets on the left are throwing a syntax error:
unexpected token {
I'...
2355
votes
68
answers
3.0m
views
Error message "error:0308010C:digital envelope routines::unsupported"
I created the default IntelliJ IDEA React project and got this:
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (...
502
votes
12
answers
377k
views
Managing jQuery plugin dependency in webpack
I'm using Webpack in my application, in which I create two entry points - bundle.js for all my JavaScript files/codes, and vendors.js for all libraries like jQuery and React. What do I do in order to ...
340
votes
32
answers
532k
views
The create-react-app imports restriction outside of src directory
I am using create-react-app. I am trying to call an image from my public folder from a file inside my src/components. I am receiving this error message.
./src/components/website_index.js Module not ...
26
votes
3
answers
57k
views
Why am I getting ReferenceError: self is not defined when I import a client-side library?
Trying to create an xterm react component in Next.js I got stuck as I'm not able to get over an error message I've never got before.
I'm trying to import a npm client-side module called xterm, but if ...
174
votes
23
answers
257k
views
Vue.js dynamic images not working with webpack
I have a case where in my Vue.js with webpack web app, I need to display dynamic images. I want to show img where file name of images are stored in a variable. That variable is a computed property ...
394
votes
18
answers
407k
views
Passing environment-dependent variables in webpack
I'm trying to convert an angular app from gulp to webpack. in gulp I use gulp-preprocess to replace some variables in the html page (e.g. database name) depending on the NODE_ENV. What is the best way ...
201
votes
7
answers
268k
views
Define global variable with webpack
Is it possible to define a global variable with webpack to result something like this:
var myvar = {};
All of the examples I saw were using external file require("imports?$=jquery!./file.js")
170
votes
6
answers
145k
views
Dynamically import images from a directory using webpack
So here's my current workflow for importing images and icons in webpack via ES6:
import cat from './images/cat1.jpg'
import cat2 from './images/cat2.svg'
import doggy from './images/doggy.png'
import ...
13
votes
3
answers
30k
views
CORS error even after setting Access-Control-Allow-Origin or other Access-Control-Allow-* headers on client side
I have a Vue application generated with webpack-simple option. I am trying to make a GET request to https://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en but I get the error: ...
194
votes
9
answers
229k
views
How do I use /deep/ or >>> or ::v-deep in Vue.js?
So, I've read here that in Vue.js, you can use /deep/ or >>> in a selector in order to create style rules that apply to elements inside of child components. However, attempting to use this in ...
439
votes
37
answers
648k
views
How to Polyfill node core modules in webpack 5
webpack 5 no longer do auto-polyfilling for node core modules.
How to fix it please?
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer ...
231
votes
14
answers
646k
views
Correct path for img on React.js
I have some problem with my images on my react project. Indeed I always thought that relative path into src attribute was built on the files architecture
Here my files architecture:
components
...
209
votes
14
answers
662k
views
"You may need an appropriate loader to handle this file type" with Webpack and Babel
I am trying to use Webpack with Babel to compile ES6 assets, but I am getting the following error message:
You may need an appropriate loader to handle this file type.
| import React from 'react';
| /...
554
votes
19
answers
1.0m
views
Getting Unexpected Token Export
I am trying to run some ES6 code in my project but I am getting an unexpected token export error.
export class MyClass {
constructor() {
console.log("es6");
}
}