Tag: webpack

Electron和Webpack ENOENT:没有这样的文件或目录,打开“/path.txt”

我是一个初学者试图使用与Webpack捆绑在一起的Electron(以前的Atom)和Reactjs。 一切工作正常,直到我试图使用Electron的远程模块访问我的React组件中的mainWindow。 尝试导入这个模块,我得到臭名昭着的错误: Uncaught Error: ENOENT: no such file or directory, open '/path.txt' 我试过重新安装电子,我检查了node_modules / electron,发现path.txt在那里。 这是我的webpack.config.js: var webpack = require('webpack'); module.exports = { context: __dirname, entry: { app: ['webpack/hot/dev-server', './src/App.jsx'], }, target: 'node', output: { path: './public/built', filename: 'bundle.js', publicPath: 'http://localhost:8080/built/' }, devServer: { contentBase: './public', publicPath: 'http://localhost:8080/built/' }, module: { loaders: [ { […]

无法parsing'babel-loader'

我正在尝试configuration我的第一个节点反应的应用程序。 我不断收到一个错误,说“无法parsingbabel-loader”。 用Googlesearch这个错误,我发现了一些不起作用的build议。 首先是将以下内容添加到我的webpack.config.js中 // resolveLoader: { // modulesDirectories: '/usr/local/lib/node_modules' // }, 尝试产生一个错误,说: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. – configuration.resolveLoader has an unknown property 'modulesDirectories'. These properties are valid: object { alias?, aliasFields?, cachePredicate?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, […]

我如何获得Karma + Webpack来查找模块?

我想在webpack通过Karmatesting运行器将它们组合在一起之后在一堆模块上运行我的testing,但是每当我运行我的testing时,Karma说, “错误:找不到模块”hello.js“在http:// localhost:9877 / base / src / hello.spec.js?d301966ffc1330826574d9d8fff5a644c3390c68:47 ” 我有一个spec文件: var a = require('hello.js'); describe("a test test", function() { it("humperdink test", function() { expect(a).toEqual('humperdink'); }); //end it }); //end describe hello.js是这样的: var a = 'humperdink'; module.exports = a; 这两个文件都在同一个文件夹中。 我的karma.conf.js是: module.exports = function (config) { config.set({ frameworks: ['jasmine'], files: [ 'src/**/*.js', 'tests/**/*.spec.js' ], preprocessors: […]

Webpack:如何使用webpack-dev-server编译,写入磁盘并提供静态内容(js / css)

我想构build我的js / css代码,将它写在磁盘上,并使用webpack-dev-server在一个命令中提供。 我不想为生产模式设置另一台服务器。 我们该怎么做呢? 在下面分享我的webpack.config.js文件内容: module.exports = { watch: true, entry: [ './src/index.js' ], output: { path: __dirname +'/dist/', publicPath: '/dist/', filename: 'bundle.js' }, module: { loaders: [ { exclude:/(node_modules)/, loader: 'babel', query: { presets: ['es2015', 'react'] } } ] }, devServer: { historyApiFallback: true, contentBase: './' } }; 请在下面的package.json中find启动脚本: "start": "webpack-dev-server –progress –colors" […]

{React jsx babel es6 webpack}我如何评论渲染(返回(// || / ** /))?

上周我开始了一个项目。 回到我的团队之前,我想评论我的代码。 /* Just for the Syntax outlook */ class Foo extends React.Components { constructor(props) { super(props); } render() { return ( <div className='bar'> /* <p> cannot commit!!!! </p> ** Following will throw error when bundled with webpack */ // This throws error as well. <div> ) } } <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script> 代码可能看起来像评论正在工作,但目前JSbin的设置没有在ES6上设置。 当你使用jsx通过webpack运行它时,会抛出一个错误。 这里是下面的堆栈 节点v6.0.0 […]

Webpack:是否有可能在编译时评估JavaScriptexpression式?

我正在尝试为我的项目安装webpack。 该项目足够大,并提供多种语言。 我希望每个语言都提供每个入口点作为单独的文件。 我的语言文件不仅仅是简单的JSON,而是JavaScript。 所以i18n插件不符合我的需求。 解决scheme似乎与i18n插件类似: var languages = ['en', 'fr', 'de']; module.exports = languages.map(function (lang) { return { name: lang, // some other language-dependent config } }) 然后在我的一些脚本中,我想使用环境variables来要求本地化文件: var lang = …; // some environment variable, available only at compile time var l10n = require('./lang/' + lang); 但默认情况下,webpack会尝试在括号之间存储该expression式,假定稍后在浏览器中对其进行评估。 那么有没有办法告诉webpack立即评估? 或者,也许有人有一个更好的解决我的问题?

我可以使用sailsjs重新加载webpack的热模块吗?

我正在使用sails.js进行一个项目并作出反应 。 我希望能够使用Webpack的热模块更换,所以我可以编辑我的代码,并立即在浏览器上更改。 不过,我怎样才能把这一切联系起来似乎并不明显。 我希望能够使用$ sails lift并只是工作。 如果这是一个node.js项目,我简单地configurationwebpack使用react-transform-hmr并从package.json启动webpack-dev-server (例如这里所描述的 )。 但是,这似乎并不是一件非常有趣的事情。 我看到模块webpack-hot-middleware声称能够“在没有webpack-dev-server情况下将热重新加载到现有服务器”。 但是,我不确定在Sails> 0.10中添加Express中间件configuration的适当位置在哪里。 任何人都可以推荐一个好的方法来设置这个?

webpack使用nodejs

我是新的反应。 我只是开始学习reactjs。 我在nodejs中使用webpack有问题。 我想创build将运行webpack文件的节点服务器。 我有webpack文件: const {resolve} = require('path'); const webpack = require('webpack'); const validate = require('webpack-validator'); const {getIfUtils, removeEmpty} = require('webpack-config-utils'); module.exports = env => { const {ifProd, ifNotProd} = getIfUtils(env) return validate({ entry: './index.js', context: __dirname, output: { path: resolve(__dirname, './build'), filename: 'bundle.js', publicPath: '/build/', pathinfo: ifNotProd(), }, devtool: ifProd('source-map', 'eval'), devServer: { […]

Webpack构build错误

与webpack有一些问题。 它build立良好,但是当我打开我的网站,我得到: Getting error: "Uncaught ReferenceError: webpackJsonp is not defined" 我相信我的CommonsChunkPlugin在我的应用程序捆绑之前正在运行? 这可能有助于知道我有我的configuration在src/config/webpack.config.js这是build立dist/js/ 。 阅读https://medium.com/@MarkEwersDev/note-to-self-if-you-ever-get-this-uncaught-referenceerror-webpackjsonp-is-not-defined-message-and-d354f5c4d335#.9cysuil5p和https://github.com/webpack/webpack/issues/368,但似乎没有帮助,除非我失去了一些东西。 devtool: 'source-map', entry: { vendor: [ 'react', 'react-dom', 'react-router', 'react-helmet', 'react-redux', 'moment-timezone', 'cookies-js', 'superagent', 'classnames', 'es6-promise' ], app: [ './src/client/entry', './scss/main.scss', ] } output:{ path: __dirname + '../../dist/js', filename: 'app.js' } plugins:[ new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'), new ExtractTextPlugin('../css/app.css', { allChunks: true }), […]

在webpack上使用google-api-nodejs-client进行grunt构build时的错误

我在ReactJS Webpack应用程序中使用https://www.npmjs.com/package/googleapis 。 它有一个警告,这是一个alpha版本,所以问题是可以预料的,这是我所拥有的。 npm install googleapis –save已安装好的googleapis ,添加"googleapis": "^2.0.2"到我的package.json,但是当我运行grunt build我得到了以下警告(后面有很多我将要发布的错误请求,因为它是很多文字): WARNING in ./~/googleapis/apis/index.js Critical dependencies: 41:23-44 the request of a dependency is an expression @ ./~/googleapis/apis/index.js 41:23-44 WARNING in ./~/googleapis/~/request/~/hawk/~/hoek/lib/index.js Critical dependencies: 403:34-60 the request of a dependency is an expression @ ./~/googleapis/~/request/~/hawk/~/hoek/lib/index.js 403:34-60 ~/googleapis/apis/index.js的违规行是: var Endpoint = require(endpointPath); 我得到的错误之一: ERROR in ./~/googleapis/~/request/~/hawk/~/hoek/lib/index.js Module […]