webpack中文

no window object present webpack nodejs

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using webpack with babel to compile my ecmascript 6 code. Everything works fine but if I add certain dependeciens like the requests npm package. Here are my files: main.js import os from 'os' export class User { constructor(username) { this.username = username; } register() { console.log("registering..."); } } var client = new User("hey") console.log(user.register()); webpack config: var webpack = require('webpack') module.exports = { entry: [ './src/main.js' ], output: { path: "dist", publicPath: "/dist/", filename: "stela.js" }, watch:

Webpack 4 Module parse failed: Unexpected character '@' (1:0)

匿名 (未验证) 提交于 2019-12-03 00:58:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I get this error when i try to run npm run dev to compile my scss to css. I know that issue is related to @import ERROR in ./src/scss/main.scss Module parse failed: Unexpected character '@' (1:0) You may need an appropriate loader to handle this file type. | @import "header"; @ ./src/index.js 3:0-27 src/index.js import "./scss/main.scss"; src/scss/main.sccs @import "header"; webpack.config.js ` const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const WebpackMd5Hash = require('webpack-md5-hash'); const

Running gunjs with Reactjs and webpack throws Reference Error in console

匿名 (未验证) 提交于 2019-12-03 00:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to install gun.js and run it inside a Reactjs webpack bundled app var path = require('path'), webpack = require('webpack'); module.exports = { devtool: 'source-map', target: 'node', node: { fs: 'empty' }, entry: { workboard: './src/workboard/main.js' }, output: { path: __dirname, filename: '/public/[name]/js/bundle.js' }, module: { loaders: [ { test: /.js?$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['es2015', 'react', 'stage-2', 'stage-1'] } } ], noParse: [/aws-sdk/] }, plugins: [ new webpack

webpack babel es7 async function error “TypeError: (0 , _typeof3.default) is not a function”

匿名 (未验证) 提交于 2019-12-03 00:53:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to require in api.js, but receiving the error "TypeError: (0 , _typeof3.default) is not a function". Attempting to debug this issue shows that removing "async" word makes the error disappear but I'm trying to use async. I have all the babel async plugins installed, defined in package.json and included in the plugins of webpack.config.js and .babelrc. Please help. my api.js let config = require('config'), $ = require('jquery') module.exports = { loggedIn: false, api: async (endpoint, params={}, method="GET") => { console.log

Webpack 4 and Uglify Plugin (TypeError: Cannot read property 'length' of undefined)

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having problems with Webpack 4 on a Linux machine. The build works fine in dev mode, but fail in production. It also seems to be working on a windows machine. I did try do downgrade webpack to an older version and nothing. Nodejs: v10.2.1 *TypeError: Cannot read property 'length' of undefined* at node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:59 this.workers = workers === true ? _os2.default.cpus().length - 1 : Math.min(Number(workers) || 0, _os2.default.cpus().length - 1); packge.json { "name": "webpack-demo", "version": "1.0

Upgrading to angular-6.x gives “Uncaught ReferenceError: global is not defined”

匿名 (未验证) 提交于 2019-12-03 00:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I upgraded my project from angular-5.x to angular-6.x and it started giving the following error and even creation of dummy global variable does not work as given here Angular 6 Auth0 - global not defined The error is as follows: Uncaught ReferenceError: global is not defined at Object../node_modules/has-binary2/index.js (index.js:10) at __webpack_require__ (bootstrap:81) at Object../node_modules/socket.io-parser/index.js (index.js:8) at __webpack_require__ (bootstrap:81) at Object../node_modules/socket.io-client/lib/index.js (index.js:7) at

Uncaught TypeError: Cannot read property 'bool' of undefined after upgrade reactjs

匿名 (未验证) 提交于 2019-12-03 00:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have just upgraded my reactjs project from 15.4.2 to 16.3.2 , the project compiles fine however, in the browser, I get this error: Uncaught TypeError: Cannot read property 'bool' of undefined at Object.<anonymous> (propTypes.js:3) at __webpack_require__ (propTypes.js:3) at Object.<anonymous> (propTypes.js:3) at __webpack_require__ (propTypes.js:3) at Object.exports.__esModule (propTypes.js:3) at __webpack_require__ (propTypes.js:3) at Object.<anonymous> (propTypes.js:3) at __webpack_require__ (propTypes.js:3) at Object.<anonymous>

webpack浅析

匿名 (未验证) 提交于 2019-12-02 23:43:01
前端的工程化和自动化 grunt gulp browserify webpack 当今主流 webpack vue react angular 当前市面 2 个版本 webpack 3.0 webpack 4.0 webpack 4 一、webpack 基础认识 官网地址 官网: https://webpack.js.org/ 中文: https://www.webpackjs.com/ 前身: browserify 缺点,只能转化js webpack作用? 干嘛的: 项目管理、打包、模块管理(依赖问题)、加载资源(js/css/html/png…/woff/data/vue…),转换器(loader) 前身:grunt/gulp/browserify->webpack->pratcle webpack的历史 webpack1支持CMD和AMD,同时拥有丰富的plugin和loader,webpack逐渐得到广泛应用。 webpack2 支持ES Module,分析ESModule之间的依赖关系,webpack1必须将ES,Module转换成CommonJS模块,2支持tree sharking webpack3 新的特性大都围绕ES Module提出,如Scope Hoisting和Magic Comment; 前端的模块化 AMD : require.js CMD : sea

webpack学习笔记

喜欢而已 提交于 2019-12-02 03:45:45
一、简介 webpack:JavaScript应用的静态 模块打包 工具 grunt/gulp(其它打包工具) grunt/gulp的核心是配置一系列的task,定义task要处理的事务(es6、ts转换,图片压缩,scss转css) 让grunt/gulp执行这些task,让整个流程自动化 grunt/gulp也被称为前端自动化任务管理工具。 当工程模块依赖非常简单是可以通过grunt/gulp进行简单的合并、压缩。 gurnt/gulp重点在于前端流程的自动化,webpack强调的是模块化开发管理,文件压缩合并只是附加功能。 二、简单使用 安装webpack 首先安装好node环境, npm install webpack@3.6.0 -g 安装低版本方便学习webpack 1.CommonJS的打包方式 // mathUtils.js function add(num1, num2) { return num1 + num2; } function mul(num1, num2) { return num1 * num2; } module.exports = { add, mul, } //main.js const {add,mul} require('mathUtils.js') console.log(add(1, 2)) console.log(mul(1, 2))

项目构建分析和 webpack 优化实践

巧了我就是萌 提交于 2019-11-30 16:15:45
项目构建分析和 webpack 优化实践 最近接手在做一个chrom浏览器插件的项目,开发过程中发现项目打包的时间很长,足足有30多秒,这是让人很难接受的,而且构建的显示了几条包体积过大的提示信息: [image:073CB50B-06EB-4779-84FE-D11087B12BD7-47140-0000087E666F3C39/1967FDC4-F9FA-44F3-922E-5406A46415FB.png] 可以看到,打包后有三个包超过了建议的体积,是什么导致了打包时间长和包的体积过大呢?下面通过一些具体方法来分析原因和解决这个问题。 什么原因导致构建包变得这么大? 为了分析是什么导致构建包为什么会变得这么大,可以安装 webpack-bundle-analyzer 插件,通过它可以直观地查看构建包中所有项目的大小。 npm install —save-dev webpack-bundle-analyzer 对应的需要在webpack 中做如下配置: webpack.config.js const { BundleAnalyzerPlugin } = require(‘webpack-bundle-analyzer’) plugins: [ ..., new BundleAnalyzerPlugin({ analyzerPort: 8081, }), ]