Tag: webpack

在电子应用程序中使用libxml-xsd失败,并出现绑定错误

我想根据电子应用程序中的模式来validationXML文件。 在包含我的libxml-xsd require语句之前,我有一个angular2服务。 只要我把它添加到我的服务文件的顶部: const xsd = require('libxml-xsd'); 我运行npm run build执行此: webpack –progress –profile –colors –display-error-details –display-cached 我在输出中看到以下新警告: WARNING in ./~/bindings/bindings.js Critical dependencies: 76:22-40 the request of a dependency is an expression 76:43-53 the request of a dependency is an expression @ ./~/bindings/bindings.js 76:22-40 76:43-53 WARNING in ./~/bindings/README.md Module parse failed: /Users/myusername/Documents/Personal/MyApp/node_modules/bindings/README.md Unexpected token (2:3) […]

更新configuration注入在运行时取configuration文件的名称,而不是硬编码

我正在使用wbepack,并在构build我的应用程序时尝试使用configuration更加dynamic。 这是一个已经被popup的create-react-app项目。 例如,如果我想在我的package.json文件中进行本地生成,我有以下几点。 "build:local": "APPLICATION_ENV=local npm run build", 我想有一个自定义的构build,我可以通过一个JSON文件,然后使用该configuration。 "custom": "APPLICATION_ENV=custom CUSTOM_ENV=test.json npm run build", 我认为这可以得到这个工作,但无论如何,我可以使dynamic的JSON文件的名称,使我可以决定使用哪个JSON文件,而不是必须在我的package.json硬编码它。 在我的脑海里是这样的: npm run build:custom CUSTOM_CONFIG=hulkhogan.json 有没有人有任何想法如何处理这个? 也许这样的事情

从输出文件中移除Webpack引导程序

那么,我知道Webpack允许我们导入带有require包,这就是Webpack的基础结构。 但是,如果不在入口文件中使用require ,那不是没用吗? 我有这个test.js条目: console.log('Test'); 和输出 /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and […]

debugging“serverless-webpack”:GraphQL错误:Lambda services-publishService在调用期间抛出一个错误

使用“无服务器-webpack”,试图部署。 我发出SLS_DEBUG=* sls deploy –verbose ,一切正常,直到: Serverless: Couldn't publish this deploy information to the Serverless Platform. Error ————————————————– GraphQL error: Lambda services-publishService threw an Error during invocation For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable. Stack Trace ——————————————– Error: GraphQL error: Lambda services-publishService threw an Error during invocation at new ApolloError (/Users/jamesfishwick/Documents/get-mobile-screen/node_modules/apollo-client/apollo.umd.js:1975:28) […]

使用webpack的时刻

我有react / redux应用程序运行在webpack并希望使用moment-timezone库。 我已经检查过我应该如何使用webpack的时间时区? 问题在这里发出,并安装json-loader如问题中所述。 但是在我的应用程序中仍然需要moment-timezone : const momentTz = require('moment-timezone'); 它会产生一个错误: ERROR in ./~/moment-timezone/index.js Module not found: Error: Cannot resolve 'file' or 'directory' /path-to-the-project/node_modules/moment-timezone @ ./~/moment-timezone/index.js 2:15-51 @ ./~/moment-timezone/index.js 2:15-51是: moment.tz.load(require('./data/packed/latest.json')); 但是,当我从生成文件夹中包含缩小的版本,它正常工作,如下所示: const momentTz = require('moment-timezone/builds/moment-timezone-with-data.min'); 更新: webpackconfiguration: let jsonLoader = require('json-loader'); loaders: [ { include: /\.json$/, loaders: [jsonLoader] } ]

客户端库的devise有什么意义?

为了解决来自Redux的警告背后的问题,我偶然发现了一些build议 , 这些build议解释了使用React或Redux为了生成针对生产使用进行了优化的构build,envifying是必要的步骤。 Envifying被解释为将诸如process.env.NODE_ENV类的节点特定的环境variablesreplace为诸如'production'类的实际值的process.env.NODE_ENV 。 接受envifying是必要的,上面的解释是真实的,它使我感到困惑,因为它似乎假设客户端库(如React和Redux)将包含特定于节点的环境variables。 是的,我知道这些库特别是build立同构/通用JavaScript应用程序的stream行,但会发现是令人惊讶的。 我是正确的理解这个? 如果是的话,那么我需要知道在节点外部使用process.env.NODE_ENV的模式的解释吗? 如果我正确理解了这个build议,那么就会提示如果我使用的是Webpack,那么我可能想使用像DefinePlugin这样的插件。 new webpack.DefinePlugin({ "process.env.NODE_ENV": process.env.NODE_ENV, }), 这似乎也要求我将NODE_ENVvariables设置为我想为我的客户端代码生成的目标环境。 这是非常奇怪的,因为我在构build服务器上设置一个环境variables,以反映实际代码在部署到的服务器上运行的环境。 所有这些让我觉得我在一般模式方面失去了一些东西。 相关信息: https://github.com/reactjs/redux/issues/1029 https://github.com/reactjs/redux/issues/1298

Backbone Marionette和Webpack – Uncaught TypeError:无法读取未定义的属性'radio'

我最近在我的webpack / backbone / marionette项目上做了一个npm安装 ,一切都破裂了。 我现在不断得到这个错误,当我的应用程序运行: Uncaught TypeError:无法读取未定义的属性“收音机” backbone.marionette.js线3328 this.channel = _.result(this, 'channel') || Backbone.Wreqr.radio.channel(this.channelName); 骨干 :1.2.3(我也试过了今天的1.3.1的全新版本) 木偶 :2.4.4 Webpack :1.12.14 幸运的是我的旧node_modules的备份,并注意到在木偶库文件夹结构中的这种差异。 任何想法发生了什么? 我没有碰到我的package.json,我只是重新运行npm install,看起来像npm / node的新版本。 更新我发现这个线程至less有一个人有完全相同的问题,但我仍然没有解决schemehttps://github.com/marionettejs/backbone.marionette/issues/2559

React未定义ReferenceError? 我正在使用webpack和webpack-dev-server

这是我的jsx : var React = require('react'); var ReactDOM = require('react-dom'); ReactDOM.render( <h1>hello world</h1>, document.getElementById('content') ) 我用webpack build/bundle.js & 我将bundle.js导入index.html index.html的: <!DOCTYPE html> <html> <head> ┊ <meta charset="utf-8"> ┊ <meta name="viewport" content="width=device-width"> ┊ <title></title> </head> <body> ┊ <div id="content"></div> ┊ <script src="./build/bundle.js" type="text/javascript" charset="utf-8"></script> </body> </html> 但是当我运行webpack-dev-server ,chrome控制台错误: bundle.js:57 Uncaught ReferenceError: React is not defined 我相信,我已经运行npm […]

npm启动webpack的问题?

我有小应用程序的反应,并试图启动与npm开始 – package.json – “脚本”:{“开始”:“节点server.js” 所有在Windows中工作正常,但试图在Ubuntu控制台上启动此引发错误 /var/www/react_pwa/node_modules/webpack/lib/RuleSet.js:143 抛出新的错误(“选项/查询不能用于装载机”); 我已经更新了node.js和npm,所以我thik这可能是webpack的configuration问题。 该文件现在看起来像这样 var path = require('path'); var webpack = require('webpack'); var HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { devtool: 'eval', entry: [ 'react-hot-loader/patch', 'webpack-dev-server/client?http://localhost:3000', 'webpack/hot/only-dev-server', './src/index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/' }, plugins: [ new webpack.HotModuleReplacementPlugin(), new HtmlWebpackPlugin({ template: 'index.html' }) ], module: […]

如何运行由webpack转换的函数?

我有一个简单的库,我正在与ES6,我有一些require关键字,然后,我需要将其转换为浏览器了解它的版本, 我使用webpack使我的图书馆的浏览器版本。 这里是一个例子: main.js import Test from './test'; function callMe(){ console.log("I am damn called!"); } test.js export default function(string) { console.log("This is awesome!"); [1,2,3].map(n => n + 1); } gulpfile.js(我使用Gulp) var gulp = require('gulp'); var babel = require('gulp-babel'); gulp.task('babel', () => { return gulp.src('src/*.js') .pipe(babel({ presets: ['es2015'] })) .pipe(gulp.dest('dist/babel')); }); var webpack = require('gulp-webpack'); gulp.task('webpack', […]