Tag: webpack

如何确定安装的webpack版本

特别是在从webpack v1到v2的过渡期间,以编程方式确定安装什么webpack版本将是非常重要的,但我似乎无法find合适的API。

使用电子应用程序的webpack捆绑错误`无法parsing模块'electron'`

我正尝试用React创build一个Electron应用程序。 我使用Webpack编译React JSX语法,但是当我尝试使用webpack命令编译时,出现这个错误: ./app.jsx中的错误找不到模块:错误:无法parsing/ Users / masterT / Downloads / gist中的模块'electron' @ ./app.jsx 6:18-37 这是应用程序代码 。 我做错了什么? 谢谢!

Webpack手表()有多个入口点 – 发射未修改的文件包?

在我的webpack.config.js中,我有3个单独的入口点,一个用于JS包,一个用于主SCSS包,另一个用于单独的SCSS包,与主SCSS包没有任何关系。 当我使用webpack.watch()API时,出于某种原因编辑JS源文件,不仅导致JS包被重新编译,而且导致2个SCSS包。 为什么是这样的,我怎样才能停止这种行为,并确保只有编辑的入口点重新编译? 这是一个问题的原因是我使用浏览器同步,对于CSS捆绑重编译即时注入CSS而不是重新加载,但在HTML / JS编辑其重新加载。 但是,如果我编辑SCSS,它也重新编译JS / HTML浏览器同步触发一个重新加载,而不是一个CSS注入

尝试在Webpack上使用带有node-webkit目标的mongoose

我使用webpack并将其作为node-webkit的构build输出。 我想要求我的项目中的mongoose模块连接到mongodb,但是当我尝试打包项目时,它总是说明一些错误: WARNING in ./~/mongoose/~/mongodb/~/mongodb-core/~/bson/~/bson-ext/ext/index.js Module not found: Error: Cannot resolve 'file' or 'directory' ./win32/x64/bson in /Users/Johannes/Documents/Development/holmes/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/ext @ ./~/mongoose/~/mongodb/~/mongodb-core/~/bson/~/bson-ext/ext/index.js 6:10-37 WARNING in ./~/mongoose/~/mongodb/~/mongodb-core/~/bson/~/bson-ext/ext/index.js Module not found: Error: Cannot resolve 'file' or 'directory' ./win32/ia32/bson in /Users/Johannes/Documents/Development/holmes/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/ext @ ./~/mongoose/~/mongodb/~/mongodb-core/~/bson/~/bson-ext/ext/index.js 8:10-38 WARNING in ./~/mongoose/~/mongodb/~/mongodb-core/~/bson/~/bson-ext/ext/index.js Module not found: Error: Cannot resolve 'file' or 'directory' ../build/Release/bson in /Users/Johannes/Documents/Development/holmes/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/ext @ ./~/mongoose/~/mongodb/~/mongodb-core/~/bson/~/bson-ext/ext/index.js […]

即使在显示捆绑包有效消息之后,Webpack-dev-server也不捆绑

我已经用webpack设置了一个基本的反应应用程序,但是我无法使webpack-dev-server正常运行。 我已经全局安装了webpack-dev-server ,并试图运行命令sudo webpack-dev-server –hot因为需要热重载。 该项目似乎只与webpack cmd工作正常。 它构build到我的生成文件夹,我可以通过一些服务器,但它不会与webpack-dev-server 。 从terminal清楚,构build过程已经完成,没有错误被抛出[ webpack: bundle is now VALID. ]它实际上正确地观察,因为任何改变它会触发构build过程,但它并没有真正build立[它不服务我的bundle.js]。 我试图改变整个configuration,仍然无法解决问题。 如果有人能帮忙,我们将非常感激。 以下是我的webpack.config.js文件。 var path = require('path'); module.exports = { devtool: '#inline-source-map"', watch: true, colors: true, progress: true, module: { loaders: [{ loader: "babel", include: [ path.resolve(__dirname, "src"), ], test: /\.jsx?$/, query: { plugins: ['transform-runtime'], presets: ['es2015', 'react', 'stage-0'], […]

Webpack – sass loader无法find图片

sass loader文档说: "If you're just generating CSS without passing it to the css-loader, it must be relative to your web root" 。 所以我做了,因为它告诉,我有我的index.html在我的project root ,然后我试图从我的scss文件加载image 。 现在我有两个错误:1)从Chrome's console : Cannot find module "./img/header.jpg" 。 2)从我的terminal : ERROR in ./~/css-loader!./~/sass-loader!./~/resolve-url-loader!./public/css/header.scss Module not found: Error: Cannot resolve 'file' or 'directory' ./img/header.jpg in C:\Web-Development\React\Portfolio\public\css @ ./~/css-loader!./~/sass-loader!./~/resolve-url-loader!./public/css/header.scss 6:64-91 webpack.config.js […]

如何在webpack的入口中添加通配符映射

我需要将脚本文件夹中的所有js文件全部包装好。我试过了 module.exports = { module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loaders: ["babel-loader"], } ], }, entry: "./src/scripts/*.js", output: { path: './src/build', filename: '[name].js' } }; 我得到这样的错误, ERROR in Entry module not found: Error: Cannot resolve 'file' or 'directory' ./s rc/scripts/* in E:\Web project\ReactJS\react-tutorial resolve file E:\Web project\ReactJS\react-tutorial\src\scripts\* doesn't exist E:\Web project\ReactJS\react-tutorial\src\scripts\*.webpack.js doesn't […]

如何在与webpack / browserify捆绑时排除代码path?

我有一个可以与node.js和浏览器一起使用的库。 我正在使用CommonJS,然后使用webpack发布为web版本。 我的代码如下所示: // For browsers use XHR adapter if (typeof window !== 'undefined') { // This adapter uses browser's XMLHttpRequest require('./adapters/xhr'); } // For node use HTTP adapter else if (typeof process !== 'undefined') { // This adapter uses node's `http` require('./adapters/http'); } 我遇到的问题是,当我运行webpack(browserify会做同样的)生成的输出包括http及其所有依赖关系。 这导致一个巨大的文件,这是不是最佳的浏览器性能。 我的问题是如何在运行模块捆绑器时排除节点代码path? 我通过使用webpack的外部解决scheme暂时解决了这个问题,只是在包含'./adapters/http'时才返回undefined。 这并不能解决其他开发人员依赖我的库使用CommonJS的用例。 他们的构build最终会遇到相同的问题,除非他们使用类似的排除configuration。 我已经看过使用envify,只是想知道是否有另一个/更好的解决scheme。 谢谢!

Webpack的后端?

我只是想知道,我开始使用Webpack进行一个新的项目,到目前为止工作正常。 我几乎会说我喜欢它比我之前使用的Grunt更好。 但现在我很困惑,我应该如何和我的Express后端使用它? 看,我正在创build一个前端(ReactJS)和后端(ExpressJS)的应用程序。 该应用程序将在Heroku上发布。 现在看起来我也应该使用ExpressJS的Webpack,通过一个命令(前端和后端)启动和运行应用程序。 但是写这篇博文的人似乎使用Webpack将所有的后端js文件捆绑在一起,这在我看来确实没有必要。 为什么要捆绑我的后端文件? 我想我只是想运行后端,观察我的后端文件进行更改,并将剩下的Webpackfunction用于前端。 你们如何捆绑前端,但同时运行后端nodejs部分? 还是有什么好的理由来捆绑Webpack的后端文件?

冲突:多个资产发射到相同的文件名

我是一个想学习所有关于它的networking新手。 运行我的webpack时遇到了一个冲突告诉我: ERROR in chunk html [entry] app.js Conflict: Multiple assets emit to the same filename app.js 我该怎么做才能避免冲突呢? 这是我的webpack.config.js: module.exports = { context: __dirname + "/app", entry: { 'javascript': "./js/app.js", 'html': "./index.html", }, output: { path: __dirname + "/dist", filename: "app.js", }, resolve: { extensions: ['.js', '.jsx', '.json'] }, module: { loaders: [ { test: […]