Webpack

I want to use mediainfo.js in React.js without 'eject' command

不羁的心 提交于 2021-02-07 16:40:59
问题 I'm trying to use mediainfo.js with React.js. Looking at the usage example in React.js of the above site, it is set by "webpack.config.js". However, when I build the environment using create-react-app , "webpack.config.js" is wrapped and it seems that it can not be edited without executing the 'eject' command. If you use npm package "react-app-rewired", you can edit it without executing the reject command, so I tried it. // config-override.js (overwrites webpack.config.js) const { resolve } =

I want to use mediainfo.js in React.js without 'eject' command

混江龙づ霸主 提交于 2021-02-07 16:40:15
问题 I'm trying to use mediainfo.js with React.js. Looking at the usage example in React.js of the above site, it is set by "webpack.config.js". However, when I build the environment using create-react-app , "webpack.config.js" is wrapped and it seems that it can not be edited without executing the 'eject' command. If you use npm package "react-app-rewired", you can edit it without executing the reject command, so I tried it. // config-override.js (overwrites webpack.config.js) const { resolve } =

Webpack - $ is not a function

…衆ロ難τιáo~ 提交于 2021-02-07 13:25:54
问题 I am moving an existing webapp from requirejs to webpack. I have an issue with the way jQuery is imported/shimmed. In my bundled js, I am getting a $ is not a function error from within the bootstrap javascript. When I console.log($) from within the bundled script it reveals an empty object: object {} I am assuming that this is because nothing is exported from jQuery as it would traditionally set $ to the window object and be done. Some research pointed me to use webpack plugins (see my

Independent custom webpack config without the webpackJsonp

ⅰ亾dé卋堺 提交于 2021-02-07 13:14:05
问题 We have a standard Angular 8 app, but for some specific business-related reasons we need to have some on-the-side javascript functions exposed. In order to use one build and to be able to reuse code from the angular application, we use a custom webpack config like this: "customWebpackConfig": { "path": "./webpack.exposed.js", "replaceDuplicatePlugins": true, "mergeStrategies": { "module.rules": "append" } } The contents of the webpack.exposed.js : module.exports = { entry: { 'for-others': '.

Independent custom webpack config without the webpackJsonp

烂漫一生 提交于 2021-02-07 13:05:38
问题 We have a standard Angular 8 app, but for some specific business-related reasons we need to have some on-the-side javascript functions exposed. In order to use one build and to be able to reuse code from the angular application, we use a custom webpack config like this: "customWebpackConfig": { "path": "./webpack.exposed.js", "replaceDuplicatePlugins": true, "mergeStrategies": { "module.rules": "append" } } The contents of the webpack.exposed.js : module.exports = { entry: { 'for-others': '.

Angular component library - image references in templates

自作多情 提交于 2021-02-07 11:59:28
问题 I have an npm package that has a number of angular components. In their templates, they reference images. If I copy the images to my application's images directory, the references resolve, but this feels stupid. Is there a way to have webpack handle image writing so that when App B includes components from App A, the images work in the build and there's no manual copy step involved? 回答1: If images are not properly required in this npm package then webpack won't be able to process them. You

Webpack Error - configuration.node has an unknown property 'fs'

白昼怎懂夜的黑 提交于 2021-02-07 11:51:46
问题 I have encountered an error when using the latest version of Webpack (5.1.0). It looks like the configuration is throwing an error because the validation schema is too restrictive. Here is my webpack configuration file in a gist, and the error message I am seeing. Webpack.config.js https://gist.github.com/adarshbhat/3ec5950b66b78102da0cf46e51a3d633 Error [webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema. -

“ReferenceError: WebSocket is not defined” when using RxJs WebSocketSubject and Angular Universal

旧城冷巷雨未停 提交于 2021-02-07 11:46:33
问题 I'm setting up an angular 6.x univeral project in order to leverage its SSR (Server-Side Rendering) capabilities. In my app, I'm using websocket communication using RxJs. More specifically, I'm, using WebSocketSubject and webSocket in my angular universal 6.x project, which works fine on the browser platform. However, when running the node web server (that contains the SSR stuff (Server-Side Rendering)), an error is thrown: ReferenceError: WebSocket is not defined Example code: // not

import * as (jasmine spyOn) not writable

你。 提交于 2021-02-07 11:23:04
问题 After upgrading to babel 7.1.5 my tests fail when i'm using import * as. test.spec.js import * as Helper from "../../../../src/renderer/modules/Helper"; describe('Testing', () => { it('Should import correctly', () => { console.log(Helper.test()) // a spyOn(Helper, 'test').and.returnValue('b'); }); }); Helper.js function test() { return 'a' } export {test} ERROR 'Upgrade.spec.js (7:8)', 'a' Error: <spyOn> : test is not declared writable or has no setter Usage: spyOn(<object>, <methodName>) at

import * as (jasmine spyOn) not writable

て烟熏妆下的殇ゞ 提交于 2021-02-07 11:22:34
问题 After upgrading to babel 7.1.5 my tests fail when i'm using import * as. test.spec.js import * as Helper from "../../../../src/renderer/modules/Helper"; describe('Testing', () => { it('Should import correctly', () => { console.log(Helper.test()) // a spyOn(Helper, 'test').and.returnValue('b'); }); }); Helper.js function test() { return 'a' } export {test} ERROR 'Upgrade.spec.js (7:8)', 'a' Error: <spyOn> : test is not declared writable or has no setter Usage: spyOn(<object>, <methodName>) at