webpack-2

How to write Webpack plugin which adds modules to the bundle on the fly based on other modules?

北慕城南 提交于 2019-12-02 20:01:18
I have a problem with writing a Webpack plugin for a translation service. The goal is to: Get names (and source code) of all required modules during compilation. I need to be able to scan the included source code for special t() function usage but I want to scan only those modules which will be included in the bundle (which, depending on build configuration, can be a subset of all project modules). Based on the gathered modules, I want to create additional modules (with translations) on the fly and add them to the bundle. Those modules need to be able to import their own dependencies. An

Unexpected character '@' You may need an appropriate loader to handle this file type

谁说我不能喝 提交于 2019-12-02 10:31:20
问题 This is what I get when I try to run webpack: the error I get is: "ERROR in ./v3/app/styles/main.scss Module parse failed: /Users/vovina/widget-login-react/v3/app/styles/main.scss Unexpected character '@' (1:0) You may need an appropriate loader to handle this file type." it can't resolve @import , any ideas on this? my webpack config is as follow: const childProcess = require('child_process') const CopyWebpackPlugin = require('copy-webpack-plugin') const ExtractTextPlugin = require('extract

Webpack There are multiple modules with names that only differ in casing

别来无恙 提交于 2019-12-02 07:17:07
I have something like this: WARNING in C:/Data/.../letsTest.jsx There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * C:\Data\...\node_modules\babel-loader\lib\index.js?presets[]=es2015&presets[]=react&presets[]=stage-0&presets[]=stage-2!C:\Data\...\letsTest.jsx Used by 4 module(s), i. e. multi C:/Data/Doc/13/13080801/LetsTest/letsTest.jsx * C:\Data\...\node_modules\babel-loader\lib\index.js?presets[]=es2015&presets[]=react&presets[]

How to import CSS files into webpack?

萝らか妹 提交于 2019-12-01 15:45:23
According to the documentation , CSS file should just be import ed. I am just starting with webpack and tried to import a CSS file but I get a message about a module missing: D:\Dropbox\dev\jekyll\blog>webpack --display-error-details Hash: 0cabc1049cbcbdb8d134 Version: webpack 2.6.1 Time: 74ms Asset Size Chunks Chunk Names build.js 2.84 kB 0 [emitted] main [0] ./webpack/entry.js 47 bytes {0} [built] ERROR in ./webpack/entry.js Module not found: Error: Can't resolve 'navbar.css' in 'D:\Dropbox\dev\jekyll\blog\webpack' resolve 'navbar.css' in 'D:\Dropbox\dev\jekyll\blog\webpack' Parsed request

How to get image that is within a data attrbute with Webpack 2?

孤街浪徒 提交于 2019-12-01 13:55:58
I am using .pug templates for my HTML and standard src attributes on my images like so: img(src=`../images/${image}`) When I run webpack -p , any images defined in the src 's of my images are found by Webpack and placed into my dist directory. This is exactly what I would expect to happen. However, I now have a requirement to lazy load my images, so I want to place the reference to the image into a data-src attribute instead of the standard src , like so: img(data-src=`../images/${image}` src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7') Running webpack -p

How to import CSS files into webpack?

坚强是说给别人听的谎言 提交于 2019-12-01 13:52:17
问题 According to the documentation, CSS file should just be import ed. I am just starting with webpack and tried to import a CSS file but I get a message about a module missing: D:\Dropbox\dev\jekyll\blog>webpack --display-error-details Hash: 0cabc1049cbcbdb8d134 Version: webpack 2.6.1 Time: 74ms Asset Size Chunks Chunk Names build.js 2.84 kB 0 [emitted] main [0] ./webpack/entry.js 47 bytes {0} [built] ERROR in ./webpack/entry.js Module not found: Error: Can't resolve 'navbar.css' in 'D:\Dropbox

specifying a complete sub directory in webpack 2 entry

半腔热情 提交于 2019-12-01 12:53:26
问题 I have a webpack 2 configuration as follows: module.exports = { context: __dirname, entry: [ "./app.ts", "./tab.ts", "./client/clientService.ts", "./client/clientSearchComponent.ts", "./infrastructure/messageComponent.ts", "./infrastructure/typeaheadComponent.ts", "./url.ts"], output: { filename: "./wwwroot/js/admin/admin.js" }, devtool: "source-map", module: { rules: [ { test: /\.ts$/, use: 'ts-loader' } ] } }; This is imported into a gulp task as follows... gulp.task("admin:js", function

`Unexpected token import` in `webpack.config.babel.js` when using `{modules: false}`

守給你的承諾、 提交于 2019-12-01 02:12:24
I have a React project which uses Webpack as the module bundler, and babel-loader to transform it into ES5, using the following settings: module: { rules: [ { test: /\.jsx?$/, exclude: /node_modules/, use: [ { loader: "babel-loader" } ] } ] }, The options are set in a stand-alone .babelrc file. Babel 6.13.0 supports ECMAScript modules, which means ECMAScript modules doesn't need to be transformed into CommonJS modules first. To get this behaviour, the documentation says that we should use this setting in our .babelrc . { presets: [["es2015", { "modules": false }], "react"] } However, when I

How do I get tslint to watch for changes in a specific folder?

落爺英雄遲暮 提交于 2019-12-01 02:00:21
问题 I am using webpack 2, and it will tell me if there are compile issues with my typescript code. However, I have not figured out a way to run tslint through it and have it run with every change detected by webpack when its running in dev-server mode. I have tried getting tslint-loader working, but for each file in my project it simply tells me: /src/main.tsNo valid rules have been specified I am using it as such: rules: [ { test: /\.ts$/, enforce: 'pre', loader: 'tslint-loader', options: {

`Unexpected token import` in `webpack.config.babel.js` when using `{modules: false}`

烂漫一生 提交于 2019-11-30 16:26:30
问题 I have a React project which uses Webpack as the module bundler, and babel-loader to transform it into ES5, using the following settings: module: { rules: [ { test: /\.jsx?$/, exclude: /node_modules/, use: [ { loader: "babel-loader" } ] } ] }, The options are set in a stand-alone .babelrc file. Babel 6.13.0 supports ECMAScript modules, which means ECMAScript modules doesn't need to be transformed into CommonJS modules first. To get this behaviour, the documentation says that we should use