Tag: webpack

无法加载/需要节点中的任何CSS文件

我有一个基于这个样板的ReactJS应用程序。 我只是试图加载和require或import一个CSS文件(embedded<style>标签,而不是CSS链接)。 以下是我尝试过的两种方法,而不是同时进行。 方法1:在Webpack中configuration加载器 这些都是我尝试过的所有加载器configuration,但仍然导致这个错误: [require-hacker] Trying to load "something.css" as a "*.js" dev.config.js module: { loaders: [ // loaders in here ] } { test: /\.css$/, loader: "style!css" } { test: /\.css$/, loader: 'style-loader!css-loader'}从这里开始 { test: /\.css$/, loader: 'style!css!postcss' } { test: /\.css$/, loader: 'style!css?modules&localIdentName=[name]—[local]—[hash:base64:5]!postcss' } { test: /\.css$/, use: [ { loader: 'css-loader', […]

当使用angular version 2.4.9,typescript&webpack version 2.2.1时,属性'map'在types'Observable <Response>'上不存在

我正在尝试从Angular 2应用程序访问web api方法,我能够使用web api获取logging。 但问题是,显示属性“地图”的 service.ts文件不存在types“可观察”错误。 示例代码: import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; import { Observable } from 'rxjs/Observable'; import 'rxjs/Rx'; @Injectable() export class ContactServices { private url = 'http://localhost:51498/api/test/'; constructor(private http: Http) { } getContacts():Observable<Object[]> { return this.http.get(this.url + 'GetContacts') .map(response => response.json()) .catch(error => { console.log(error); return […]

我是否需要将我的server.js添加到我的webpack文件中?

我有一个es6语法的节点服务器,像导入语句,它无法识别。 我很确定我将不得不添加到我的webpack文件,但不知道如何做到这一点,是否需要。 我的节点服务器文件被称为server.js var webpack = require('webpack'); module.exports = { entry: { app: './src/index.js', vendor: './src/vendor.js' }, output: { path: __dirname, publicPath: '/', filename: '[name].js' }, plugins: [ new webpack.optimize.CommonsChunkPlugin('vendor','vendor.js', Infinity) ], module: { loaders: [{ exclude: /node_modules/, loader: 'babel', query: { presets: ['react', 'es2015', 'stage-1'] } }] }, resolve: { extensions: ['', '.js', '.jsx'] […]

为什么即使webpack不抛出任何错误,React组件不渲染?

APP-client.js var React = require('react'); var APP = require('./components/APP'); React.render(<APP />, document.getElementById('react-container')); App.js (component)var React = require('react'); var APP = React.createClass({ render() { return (<h1>Hello World form React</h1>); } }); module.exports = APP; webpack.config.js我有问题与webpack,但解决了预设添加。 现在运行良好。 module.exports = { entry: "./app-client.js", output: { filename: "public/bundle.js" }, module: { loaders: [ { exclude: /(node_modules|app-server.js)/, loader: "babel-loader", query: […]

在后端应用程序中使用Webpack会降低性能吗?

我正在研究使用AWS Lambda和NodeJS的无服务器应用程序。 我正在考虑使用Webpack将我所有的NodeJS后端代码捆绑到一个JavaScript文件中,并使用像树震动一样的function。 对于我理解Node的方式, import (或require )在运行时被parsing。 我担心,将所有文件捆绑在一个文件中会影响我的应用程序的性能,因为它总是加载整个JS文件,而不是只加载JS代码执行过程中parsing的JS文件。 对于一个小应用程序,我的影响是小的,但随着我的应用程序的增长,捆绑也会。 我可以创build多个包,每个包都有一个Lambda函数,但是我的问题是:我的问题是否有效? 在单纯的NodeJS上下文中,将所有文件捆绑到单个文件中会影响我的性能,即使只是一小部分? 注意:AWS Lambda 确实支持ES5,因此仅使用Webpack进行转储并不是这里的一个因素。

yargs – require函数用于不能静态提取依赖关系的方式

我正在尝试为我正在开发的一个项目开发一个模块。 在将一些核心代码拆分到一个单独的目录并尝试使用import Noxel from 'noxel'来包含模块之后,会出现一些警告/错误。 node_modules/noxel/index /* Create the core Noxel class */ const Noxel = function () { this.start = require('./bin/dev-server') //this.sendRequest = require('./lib/sendRequest') } Noxel.prototype.init = require('./lib/init') module.exports = new Noxel() 在我的索引文件中包含通过const Noxel = require('noxel')文件正常工作: /index const Noxel = require('noxel') const models = require('./models') /* Init Noxel */ Noxel.init({ models: models }) Noxel.start() […]

在React-Native中使用Node.js内置模块的polyfills

我想在React-Native应用程序中使用的一些Node.js包依赖于Node.js的内置模块,如url , http和crypto 。 这些包被devise成与Webpack一起打包,并利用Webpack的polyfills 。 我已经添加了所需的polyfills到我的根package.json文件,但我仍然看到像在我的应用程序Unable to resolve module 'crypto'错误。 我如何告诉React-Native打包程序使用polyfill而不是尝试加载内置的Node.js模块?

can'ffind“process.env.NODE_ENV”

每当我在configuration文件中看到variablesprocess.env.NODE_ENV总是困扰我,特别是webpack.config.js 。 我在哪里可以find这个? 因为有时候我想改变它的价值而不是development 。

如何通过AJAX加载容器应用程序中的React组件

什么是通过AJAX在现有的React应用程序中加载/插入React组件的最佳实践。 我正在考虑通过AJAX加载各种React组件的“容器应用程序”。 这怎么可能呢? 这与webpack如何工作?

你如何获得在vuejs组件unit testing中定义的“this”variables

我想在npm脚本中使用mocha-webpack来testing一个vuejs组件。 我在testing中嘲笑这样的vuex商店: const vm = new Vue({ template: '<div><test></test></div>', store: new Vuex.Store(mockedStore), components: { 'test': TestItems } }).$mount() 我在组件上调用一个方法来testing,例如: vm.$options.components.test.methods.foo() 在组件中,我有访问商店的代码,例如: this.$store.commit('bar', data) 问题是,当它到达这一点,我得到这个错误: 'Cannot read property \'commit\' of undefined' undefined undefined 我证实在这方面“这个”是未定义的。 当我运行应用程序时,“this”被定义并且具有“$ store”。 我如何使它在unit testing环境中工作?