Tag: webpack

asynchronous/等待不等待

我遇到了一个我不完全明白的问题。 我觉得有可能是我没有掌握的概念,可以优化的代码,可能还有一个错误的方法。 要大大简化整体stream程: 向外部API发出请求 对返回的JSON对象进行分析并扫描链接引用 如果find任何链接引用,则会使用真正的JSON数据填充/replace链接引用 一旦所有链接引用被replace,原始请求将被返回并用于构build内容 这里是原始请求(#1): await Store.get(Constants.Contentful.ENTRY, Contentful[page.file]) Store.get代表: async get(type, id) { return await this._get(type, id); } 哪些电话: _get(type, id) { return new Promise(async (resolve, reject) => { var data = _json[id] = _json[id] || await this._api(type, id); console.log(data) if(isAsset(data)) { resolve(data); } else if(isEntry(data)) { await this._scan(data); resolve(data); } else […]

让webpack热点更新在我的同构web应用程序中正常工作

我正在创build一个节点/expression后端和反应前端的Web应用程序。 我(我想)大部分已经启动并运行了,但让浏览器执行热点刷新的最后一步并不像预期的那样工作。 我会尽力在这里发布所有相关的设置。 请让我知道,如果你需要别的什么来找出我犯了什么错误: 我用node ./server/index.js启动我的应用程序 webpack.config.js var path = require('path'); var webpack = require('webpack'); let webpackConfig = { name: 'server', output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/dist/', }, resolve: { extensions: [ '', '.js', '.jsx', '.json' ] }, module: { loaders: [ { test: /\.(js|jsx)$/, loader: 'babel-loader', exclude: /node_modules/, query:{ presets: ['es2015', […]

Eslint – 超出最大调用堆栈大小

在React / Webpack项目中工作时,我开始对eslint库有问题。 eslint软件包使用npm下载,并用于使用webpack预加载器来validation项目。 preLoaders: [{ test: /\.jsx?$/, loaders: [ 'eslint' ], include: path.resolve(__dirname, 'app') }] 它曾经工作得很好,直到最近,当我试图克隆相同的项目到其他文件夹。 在安装依赖项“npm install”并启动项目“npm start”之后,出现以下错误。 ERROR in ./main.view.jsx Module build failed: RangeError: Maximum call stack size exceeded at keys (native) at Referencer.Visitor.visitChildren (project/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:78:24) at Referencer.Visitor.visit (project/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:112:14) at Referencer.Visitor.visitChildren (project/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:93:26) at Referencer.Visitor.visit (project/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:112:14) at Referencer.Visitor.visitChildren (project/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:93:26) at Referencer.Visitor.visit (project/node_modules/eslint/node_modules/escope/node_modules/esrecurse/esrecurse.js:112:14) at Referencer.Visitor.visitChildren […]

如何pipe理Webpack / Electron应用程序的configuration?

我正在使用Webpack 2和Electron在Mac上构buildnodejs应用程序。 在我的项目在根目录中我有目录“数据”,我把configuration存储在一个JSON像data / configurations / files.json(实践中有不同的文件与dynamic名称) 虽然当我打电话时, fs.readdirSync(remote.app.getAppPath()); : fs.readdirSync(remote.app.getAppPath()); 获取根文件我只得到这些打包: [ "default_app.js", "icon.png", "index.html", "main.js", "package.json", "renderer.js" ] path.join(remote.app.getAppPath(), 'data/tests/groups.json'); 用FS ReadSync调用会导致问题Error: ENOENT, data/tests/groups.json not found in /Users/myuser/myproject/node_modules/electron/dist/Electron.‌​app/Contents/Resourc‌​es/default_app.asar 。 所以看起来,整个数据文件夹是不是由networking包装拾起。 Webpack的configuration是使用json-loader ,我没有发现任何关于包含特定文件或jsons的文档。 或者我必须以不同的方式引用json文件,因为它们可能在main.js中打包。 Electron / Webpackpipe理JSONconfiguration文件的最佳做法是什么? 当我在做项目的时候,我做错了什么? 我的项目是基于https://github.com/SimulatedGREG/electron-vue使用webpack / electron / vue

什么是node-libs-browser,为什么在安装babel-loader的时候会安装它

我刚刚安装了babel loader ,使用webpack的babel。 它带来了3个额外的节点依赖关系,但只有其中2个我预期 来自babel loader package.json "peerDependencies": { "babel-core": "*", "webpack": "*" }, 那么,为什么我也越来越node-libs-browser我不知道它是什么,也不希望额外的模块在我的devDependencies

我如何将package.json版本写入到WebPack包中?

我的package.json文件包含了一个我的模块的版本,最终被编译成一个app.bundle.js文件,包含在我的web项目中。 我真的很想把package.json文件中的版本号写在app.bundle.js文件中,作为注释在文件的开头。 有WebPack插件来做到这一点或与WebPack本身的设置?

在严格模式之外还不支持的块范围声明 – Laravel Mix

我在我的Homesteadstream浪箱里运行Laravel 5.4 。 我用npm install命令安装了所有的npm依赖项。 这并没有产生任何错误。 在我的webpack.min.js文件中,我有: const { mix } = require('laravel-mix'); /* |————————————————————————– | Mix Asset Management |————————————————————————– | | Mix provides a clean, fluent API for defining some Webpack build steps | for your Laravel application. By default, we are compiling the Sass | file for the application as well as bundling […]

我怎样才能使webpack跳过一个要求

我怎样才能使webpack跳过的发生 require('shelljs/global'); 在我的源文件? 我想创build一个我的源文件包,但在文件中保留require('shelljs/global') ,而不是绑定shelljs / global。 先谢谢你 托马斯

Webpack重新编译未更改的文件,从而减慢构build时间

相关的webpack / webpack的问题。 根据我的经验,在实际项目中使用webpack会减慢一定数量的组件和/或依赖项。 我有一个testing存储库 ,试图用下面的应用程序来演示这个: 入口点是A.js ,它需要B.js和C.js B.js很小,没有太多的依赖关系。 C.js是单一的,有成千上万的需求。 我的期望是,当在testing项目中使用webpack-dev-server时,每当我保存B.js ,webpack应该认识到C.js并没有触及它的依赖关系。 它应该快速地(<10ms)编译B.js ,replace它在caching中,并从初始编译中使用A.js的caching版本输出编译后的A.js 但是,每次保存B.js时,webpack都会编译3002隐藏模块,导致编译时间为960ms 。 这本身并不坏,但如果你添加一些像react-hot和babel这样的装载机, react-hot失去控制。 我有一个解决scheme:在同一个testing项目有一个dll分支。 在那个分支上,你可以运行webpack –config webpack.dll.config.js来生成B.js和C.js两个DLL, B.js DLL在编译A.js时候会被A.js 。 之后,当使用webpack-dev-server ,每当你保存B.js ,它的DLL就会被重新编译, A.js会注意到它的一个DLL已经更新了,它只会把C.js的旧DLL和B.js新DLL,并将它们合并成一个快乐的快乐包。 我可以进一步在这个分支上做目录读取或依赖图走,为每个组件生成一个DLL,这个方法可能被应用到每个webpack项目。 这在理论上应该尽可能快地编译。 但在这一点上,在我看来,我将重新实现(糟糕的)webpack中的caching层应该做什么,所以这里发生了什么?

要求v​​m2使用电子和webpack

当我尝试使用Webpack导入Electron渲染器进程中的vm2模块时遇到错误。 import fs from 'fs' console.log('ok') const { NodeVM } = require('vm2') console.log('ko') 这是Webpack显示的错误: WARNING in ./~/vm2/lib/main.js Critical dependencies: 180:26-33 require function is used in a way in which dependencies cannot be statically extracted 335:15-22 require function is used in a way in which dependencies cannot be statically extracted 367:26-33 require function is used in […]