webpack-loader

How does css loader resolve resources in webpack

不想你离开。 提交于 2020-06-29 04:08:16
问题 I was learning about css-loader in webpack, the defination says that The css-loader interprets @import and url() like import/require() and will resolve them. What does it mean, In an example in the documentaion there is url(image.png) => require('./image.png') So my question is will it convert url('./image.png') to require('image.png') For example in a css file if i have background property as #selector{ background:url('./image.png'); //this is a vlid css property } will the above style

Webpack Loaders - create and write files inside loader

帅比萌擦擦* 提交于 2020-05-17 08:11:07
问题 Pretty much what the title suggests. I want to create a metadata file alongside every javascript file in my project. So I need a webpack loader that doesn't change the content at all, and just extracts some metadata and writes it to a file. What's the best way to do this? fs.writeFileSync seems to work fine, but I don't know if I should use it since it seems like some webpack guides recommend using something called memory-fs, webpack's in-memory filesystem. 回答1: So this took a while to find

Webpack 4 - Change a module's type in a loader

天涯浪子 提交于 2020-03-04 04:49:24
问题 Webpack 4 introduces module types, allowing better handling of JSON, CSS, ES6 modules, etc. Some loaders, like messageformat-loader, take in source of one type (in this case JSON), but output a different type (in this case JS). This currently breaks in Webpack 4. ERROR in ./src/messages.json Module parse failed: Unexpected token v in JSON at position 0 You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token v in JSON at position 0 at JSON.parse (<anonymous>)

webpack插件【cdn-loader】

被刻印的时光 ゝ 提交于 2020-03-01 14:55:40
#新出炉的 webpack插件-- cdn-loader 项目首页: https://github.com/jso0/cdn-loader 基本用法 (Usage) 在入口文件中require("cdn-loader + ? + ModuleName + @ + version + !") 注意三个符号 ? 、 @ 、 ! 示例: require('cdn?jQuery@3.1.0!') Note:模块区分大小写 功能类似与 webpack 的 externals webpack打包后 js // entry.js /***/ 15: /***/ function(module, exports) { module.exports = window.jQuery; /***/ } 手动添加到html文件 // index.html <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 高级用法 (自动生成) 更多支持可通过** html-webpack-cdn-plugin **插件自行配置... 安装 (Install) npm install -D cdn-loader TODO [x] 编写一个更新html

Load video mp4 webpack loader

爱⌒轻易说出口 提交于 2019-12-31 03:26:08
问题 How to use loader for mp4 video format with webpcak 4, I try like this: { test: /\.mp4$/, use: 'file-loader', loader: 'file-loader?name=videos/[name].[ext]', }, and import like this import pressButtonAnimated from './images/pressButtonAnimated.mp4' But it does not work for me, and I get an error You may need an appropriate loader to handle this file type. But this one is work for me, but I don wanna add in each file import pressButtonAnimated from '-!file-loader!./images/pressButtonAnimated

Load video mp4 webpack loader

旧时模样 提交于 2019-12-02 01:34:06
How to use loader for mp4 video format with webpcak 4, I try like this: { test: /\.mp4$/, use: 'file-loader', loader: 'file-loader?name=videos/[name].[ext]', }, and import like this import pressButtonAnimated from './images/pressButtonAnimated.mp4' But it does not work for me, and I get an error You may need an appropriate loader to handle this file type. But this one is work for me, but I don wanna add in each file import pressButtonAnimated from '-!file-loader!./images/pressButtonAnimated.mp4' The way how you declare your loader is not right. You are mixing two ways to define loaders. { test

Angular CLI custom webpack config

梦想的初衷 提交于 2019-11-28 23:59:22
问题 In previous versions of Angular there was an option for eject so that you could modify your webpack configuration as you please. One of the most common use cases for this feature was adding custom webpack loaders. In Angular 6 this option has been removed, so currently there is literally no way to get the webpack config (beside looking it up in angular source code). Is there any way to add a custom webpack config to Angular application that uses @angular/cli 6+? Or alternatively, is there any