Tag: webpack

用两个configuration创build一个webpack.config,但插件相同

我正在开发一个基于vue.js的项目,在那里我将有一个用于pipe理仪表板的SPA和一个公共端的SPA。 我想单独处理这些项目,但是同时build立它们。 (或者这将是很好的东西,如:运行生成 – 公共或–admin(指定要build立哪一个)) 我创build了一个configuration数组,并使用此设置创build输出,但由于某种原因,它不会缩小。 它只有一个configuration。 我试图把插件像插件分开configuration:[..]但没有成功。 webpack.config.js: var path = require('path')var webpack = require('webpack') module.exports = [ { entry: { public : './resources/js/public-spa/main.js', }, output: { path: path.resolve(__dirname, './public/public-spa/dist/'), filename: '[name].build.js', chunkFilename: "public.[name].chunk.js" }, module: { rules: [ { test: /\.vue$/, loader: 'vue-loader', options: { loaders: { 'scss': 'vue-style-loader!css-loader!sass-loader', 'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax' } } […]

如何检查在webpack中构build时的执行时间

我有几个疑问:1.我如何计算执行时间。 在webpack中构build时。 2.我怎样才能优化性能。 我正在使用Webpack DllPlugin,但无法增加构build时间的性能。

安装包后,Webpack无法编译错误

我正在使用Angular 4的一些样板代码,并且遇到问题。 它工作正常,直到我从npm下载另一个包。 我得到以下错误,命令ng服务不再起作用。 该项目已经安装了jquery,所以错误对我来说没有意义。 没有webpack.config.js文件,所以我添加了下面的代码。 任何帮助,将不胜感激。 webpack.config.js文件 var webpack = require('webpack'); var config = { plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }) ] }; module.exports = config; 错误 警告in ./~/jsdom/lib/jsdom/utils.js 216:21-40严重依赖关系:依赖关系的请求是一个expression式 警告在./~/jsdom/lib/jsdom/living/xmlhttprequest.js 20:23-30关键依赖关系:require函数的使用方式不能静态提取依赖关系 警告in ./~/ajv/lib/async.js 96:20-33严重依赖:依赖的请求是一个expression式 警告in ./~/ajv/lib/async.js 119:15-28严重依赖关系:依赖关系的请求是一个expression式 警告在./~/ajv/lib/compile/index.js 13:21-34关键依赖关系:依赖关系的请求是一个expression式 ERROR in ./~/jquery/lib/node-jquery.js Module not found:错误:无法parsing'E:\ WebstormProjects \ innovation-node-server-2.0 \ node_modules […]

运行webpack部署configuration时如何解决'window is not defined'?

我试图部署一个反应+服务器应用程序到Heroku。 总体目标是使用Heroku dyno作为通用服务器来提供静态资源,并充当我的React应用程序的API端点。 我正在编写一个部署configuration来缩小和遇到一个错误。 它缩小了,但在node dist/bundle.js它给出了以下错误。 ReferenceError: window is not defined 要使用googlemaps api,我有一个Map组件,它将全局窗口对象上的一个函数设置为initMap() ,在Map组件中定义。 并在一个loadJS()引用window.document两次。 正在开发中,它工作正常。 我使用这个post来帮助使Google地图与React协同工作 我怀疑窗口对象是未定义的,因为没有浏览器提供窗口对象。 你能证实我的怀疑吗? 需要什么来弥补这个问题? 脚本在我的package.json文件中 "scripts": { "start": "npm build && node dist/bundle.js", "dev-start": "babel-node server/buildScripts/server.js", "build":"webpack –config ./webpack.deployment.config.js", "test": "echo \"Error: no test specified\" && exit 1" }, webpack.deployment.config.js const path = require('path'); const webpack = require('webpack'); module.exports […]

如何使用webpack将jquery包含在nodejs应用程序中?

这是我的webpack.config.js var webpack = require("webpack"); module.exports = { entry: './app.js', output: { filename: './bundle.js' }, module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['es2015'] } } ], }, plugins: [ new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }) ] }; 这是我的app.js var $ = require('jquery'); global.jQuery = $; global.$ = […]

webpack&aws lambda

我正在尝试使用Weback来构build一个简单的lambda nodejs函数hello world。 exports.handler = (event, context, callback) => { callback(null, 'Hello from Lambda'); }; 该函数在lambdaexpression式中工作,处理器“index.handler”在aws lambdaconfiguration页面中configuration。 上面的Webpack生成的代码不起作用。 该函数在模块“index”上抛出错误“Handler'handler'”。 它看起来像模块成为反义词。 可以通过如下更新生成的代码来工作。 global.handler = (event, context, callback) => { //async.map(['file1','file2','file3'], console.log, function(err, results){ // results is now an array of stats for each file callback(null, 'Hello from Lambda'); //}); //add the following at the end. exports.handler […]

导入库的问题

我最近遇到了一个interact.js,我想在我的一个项目中使用一个库,但是我不能让它工作。 我已经通过npm安装它 npm install interactjs –save 它显示在我的package.json依赖关系为 "dependencies": { "angular": "^1.6.4", "angular-ui-router": "^0.4.2", "interactjs": "^1.2.9" } 而且我还在main.js中导入了其他库和模块 import 'interactjs'; 该项目是在angularjs中,我已经在我的控制器中的一个函数内使用一些interact.js语法,但我得到以下错误: app.js:57837 Uncaught Error: Module parse failed: path\controller.js Unexpected token (207:48) You may need an appropriate loader to handle this file type. | drag() { | let drag = document.querySelector('.draggable'); | interact(drag).draggable({ inertia: true; }) | […]

React / Webpack / Express渲染服务器端的问题

我试图将服务器端渲染到我现有的React / Redux应用程序中。 几次失败的尝试后,我想我几乎在那里,但我遇到了几个问题。 我对React / Redux / Express / Webpack相当陌生,所以如果我犯了一些愚蠢的错误,我很抱歉! 问题1 – 窗口未定义 当我使用Redux时,我需要跟踪初始状态并将其加载到我的应用程序中。 内部server/index.js我从商店获取初始状态,并使用window.__initialData__ = ${serialize(initialData)}存储在window.__initialData__ = ${serialize(initialData)} 。 服务器代码如下: import express from 'express'; import React from 'react'; import { renderToString } from 'react-dom/server'; import { Provider } from 'react-redux'; import { StaticRouter, matchPath } from 'react-router-dom'; import serialize from 'serialize-javascript'; import routes […]

如何将ES6转换为ES5的第三方库?

我有一个webpack安装程序几乎可以正常工作,但是当我导入一些在ES6中编写的第三方库时,UglifyJS会发出一个错误。 这里是node-postgres一个例子: module.exports = { prepareValue: function prepareValueWrapper (value) { // this ensures that extra arguments do not get passed into prepareValue // by accident, eg: from calling values.map(utils.prepareValue) return prepareValue(value) }, normalizeQueryConfig, postgresMd5PasswordHash, md5 } 这里是它应该在ES5中看起来如何: module.exports = { prepareValue: function prepareValueWrapper (value) { // this ensures that extra arguments do not get passed […]

如何运行“npm start”永远运行

当状态在线时,我正在运行8014上的端口,它仍然没有运行 当我使用pm2启动工具/ srcServer.js "scripts": { "prestart": "babel-node tools/startMessage.js", "start": "npm-run-all –parallel test:watch open:src", "open:src": "babel-node tools/srcServer.js", "test": "mocha –reporter progress tools/testSetup.js \"src/**/*.test.js\"", "test:watch": "npm run test — –watch", "clean-dist": "npm run remove-dist && mkdir dist", "remove-dist": "node_modules/.bin/rimraf ./dist", "build:html": "babel-node tools/buildHtml.js", "prebuild": "npm-run-all clean-dist test build:html", "build": "babel-node tools/build.js", "postbuild": "babel-node tools/distServer.js" } 我正在用npm start运行节点我需要运行节点来运行永远运行的服务器。 […]