OK, i have searched high and low but cannot reliably deterrmine if this is or is not possible with webpack. https://github.com/webpack/webpack/tree/master/examples/require.context Appears to indicate that one can pass a string to a function and it load a module… But my attempt is just not working: webpack.config.js The server.js The module in modules/ named test.js But the result is always the
Tag: webpack
Conflict: Multiple assets emit to the same filename
I’m a webpack rookie who wants to learn all about it. I came across a conflict when running my webpack telling me: ERROR in chunk html [entry] app.js Conflict: Multiple assets emit to the same filename app.js What should I do to avoid the conflict? This is my webpack.config.js: Answer i’m not quite familiar with your approach so I’ll show
Exclude var and json file from webpack build
I’m trying to exclude but retain external reference to a few JSON files from a webpack build. I’ve modified the webpack.config.js to include: This solved some previous errors, but now it seems that the ‘font’ var is being considered undefined. The error is referring to this line in the build, where webpack has exported the ‘font’ var as a module.export:
Webpack: Bundle.js – Uncaught ReferenceError: process is not defined
Here’s my webpack.config.js And Main.js The Bundle.js is inserted in my Index.html. The browser then gives the error: What should I change in the webpack.config.js to make this error go away? Answer You need to add a plugin to define your env (in webpack config):
Console logging error on bundle.js instead of React component
I have created a Webpack build which works fine for me – it has a dev-server which I use for hot-reloading, and a production express server that runs a template html file and integrates the bundle.js file. This is all great, except when I’m working in my dev-server, the console gives me error messages like this: Uncaught Error: Expected the
Can’t set NODE_ENV=production with npm and webpack
I’m trying to access process.env.NODE_ENV inside my app, but I only get process is not defined when I check it. package.json: webpack.config.js: const NODE_ENV = process.env.NODE_ENV ? process.env.NODE_ENV.toLowerCase() : ‘development’; and below : In the app source: And it seems that process is not defined… What am I doing wrong here? Answer I’m not totally sure if the problem came
Function from external JS file not being called
I am using webpack and firebase. I have this line in my package.json > “start”: “webpack-dev-server ./index.js”, In my index.js file I have function In my index.html file I have this line > <input type=”submit” onclick=logUserIn() value=”Log in”> When I click that button I get this error > Uncaught ReferenceError: logUserIn is not defined I also have this line in
How to disable ESLint in vue-cli?
How do I go about disabling ESlint in project generated with vue-cli? If I remove the loader: ‘eslint’ line it won’t compile, same with setting it to an empty string. I know I can opt out of ESLint during the initialization phase, but how can I disable it after my project has been created? Answer Vue’s starter projects are themselves
How to load image files with webpack file-loader
I am using webpack to manage a reactjs project. I want to load images in javascript by webpack file-loader. Below is the webpack.config.js: I used this line to load image files and copy them to dist/public/icons directory and keep the same file name. But I have two problems when using it. When I run webpack command, the image file was
Webpack-dev-server not bundling even after showing bundle valid message
I’ve set up a basic react application with webpack but I couldn’t get the webpack-dev-server running properly. I’ve installed webpack-dev-server globally and tried running the command sudo webpack-dev-server –hot as hot reloading was required. The project seems to be working fine with just webpack cmd. It builds into my build folder and I can get it working via some server