webpack-dev-server

Error `window not defined` in Node.js

爷,独闯天下 提交于 2019-11-30 11:29:52
I know window doesn't exist in Node.js, but I'm using React and the same code on both client and server. Any method I use to check if window exists nets me: Uncaught ReferenceError: window is not defined How do I get around the fact that I can't do window && window.scroll(0, 0) ? Sawtaytoes has got it. I would run whatever code you have in componentDidMount() and surround it with: if (typeof(window) !== 'undefined') { // code here } If the window object is still not being created by the time React renders the component, you can always run your code a fraction of a second after the component

How to use webpack-dev-server multiple entries point

不羁的心 提交于 2019-11-30 08:24:15
I would like to use the webpack-dev-server to host multiple entry points at one PORT. My current config is below: entry: { //Application specific code. main: [ `webpack-dev-server/client?http://${config.HOST}:${config.PORT}`, 'webpack/hot/only-dev-server', './app/base.js', './app/main.js' ], login: [ `webpack-dev-server/client?http://${config.HOST}:${config.PORT}`, 'webpack/hot/only-dev-server', './app/base.js', './app/login.js' ], }, output: { path: assetsPath, publicPath: `http://${config.HOST}:${config.PORT}/public/dist/`, chunkFilename: "[name].js", filename: '[name].js', }, But seems like

webpack+vue+vueRouter模块化构建完整项目实例超详细步骤(附截图、代码、入门篇)

半腔热情 提交于 2019-11-30 07:05:26
>开始 (确认已经安装node环境和npm包管理工具) 1、新建项目文件名为vuedemo 2、 npm init -y 初始化项目 >安装项目依赖 3、 npm install --save vue 默认安装最新版vue 4、 npm install --save-dev webpack webpack-dev-server 安装webpack,webpack-dev-server(是一个小型的Node.js Express服务器) *拓展:npm install 在安装 npm 包时,有两种命令参数可以把它们的信息写入 package.json 文件,一个是npm install --save另一个是 npm install --save-dev,他们表面上的区别是--save 会把依赖包名称添加到 package.json 文件 dependencies 键下,--save-dev 则添加到 package.json 文件 devDependencies 键下, --save-dev 是你开发时候依赖的东西,--save 是你发布之后还依赖的东西。* 5、 npm install --save-dev babel-core babel-loader babel-preset-es2015 安装babel,babel的作用是将es6的语法编译成浏览器认识的语法es5 6、

webpack dev server CORS issue

寵の児 提交于 2019-11-30 04:35:13
I am using webpack-dev-server v1.10.1 to boost up my Redux project and I have the options below: contentBase: `http://${config.HOST}:${config.PORT}`, quiet: false, noInfo: true, hot: true, inline: true, lazy: false, publicPath: configWebpack.output.publicPath, headers: {"Access-Control-Allow-Origin": "*"}, stats: {colors: true} In the JS, I am using request from superagent to generate a HTTP GET call request .get(config.APIHost + apiUrl) .set('Accept', 'application/json') .withCredentials() .end(function (err, res) { if (!err && res.body) { disptach(() => { return { type: actionType || GET

Vue项目启动代码执行流程分析

一世执手 提交于 2019-11-30 03:48:27
VUE启动流程 1. package.json 在执行npm run dev的时候,会在当前目录中寻找 package.json 文件, 有点类似 Maven 的 pom.xml 文件,包含项目的名称版本、项目依赖等相关信息。 { # 版本信息 "name": "kitty-ui", "version": "1.0.0", "description": "kitty ui project", "author": "Louis", "private": true, "scripts": { "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "start": "npm run dev", "build": "node build/build.js" }, "dependencies": { # 项目依赖 "vue": "^2.5.2", "vue-router": "^3.0.1" }, "devDependencies": { # 项目依赖 "autoprefixer": "^7.1.2", "babel-core": "^6.22.1","vue-template-compiler": "^2.5.2", "webpack": "^3.6.0", "webpack

Why am I not being able to compile SASS with Webpack?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 03:27:36
I have the following modules in my Webpack config: module: { preLoaders: [ { test: /\.vue$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ }, { test: /\.js$/, loader: 'eslint', include: projectRoot, exclude: /node_modules/ } ], loaders: [ { test: /\.vue$/, loader: 'vue' }, { test: /\.js$/, loader: 'babel', include: projectRoot, exclude: /node_modules/ }, { test: /\.json$/, loader: 'json' }, { test: /\.html$/, loader: 'vue-html' }, { test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, loader: 'url', query: { limit: 10000, name: utils.assetsPath('img/[name].[hash:7].[ext]') } }, { test: /\

EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module'

做~自己de王妃 提交于 2019-11-30 02:13:54
问题 I'm trying to lazy load Angular 2 modules with the router, and I'm having this error: error_handler.js:50 EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module' I tried all the answers that seems to be working for the others, like this one which seems to be a solution for everybody facing this issue, but doesn't work with me Lazy loading in Angular2 RC7 and angular-cli webpack here is my code: app.module import { MediatorService } from './home/mediator.service';

Set up webpack to run locally on a custom domain over HTTPS

无人久伴 提交于 2019-11-30 01:51:51
问题 In order to use a module I want to integrate into my application (I am developing locally), I have to do two things: 1) Make my application run locally on HTTPS. 2) Run the application with a specific domain. Both of these things should be pretty easy with the Webpack dev server I am using for local development, but for some reason it is not working as the documentation suggests. My webpack.config file is: module.exports = { entry: './app/js/app.js', output: { path:'./app/js/', publicPath:

Serving static assets in webpack dev server

不羁的心 提交于 2019-11-30 01:12:28
I run webpack-dev-server from the root folder of my project. I have assets folder in /src/assets that is copied by CopyWebPackPlugin: new CopyWebpackPlugin([ { from: 'src/assets', to: 'assets' } ]) If I put logo.png inside assets folder then After running webpack-dev-server I can't access http://localhost/assets/logo.png file, but can access http://localhost/src/assets/logo.png file. However if I run in production mode the situation turns upside down. How to configure webpack server to make http://localhost/assets/logo.png file accessible in development mode? You can tell webpack to use a

webpack.validateSchema is not a function

断了今生、忘了曾经 提交于 2019-11-29 22:51:08
Webpack are throwing this error all of a sudden: TypeError: webpack.validateSchema is not a function Everything was working fine Friday, not working today. No new commits to master since Friday. Pruned NPM, that didn't work, deleted NPM folder and re-installed, no dice. Checked out to previous branches which have not been rebased from Master for over a week. Still the same. Anyone have an idea? Looks like npm bug, since webpack-dev-server@2.1.0-beta.11 requires webpack@^2.1.0-beta.26 but npm failed to install it. The easiest way to avoid the issue without updating too much is to change