webpack-dev-server

How to add a js file with webpack?

五迷三道 提交于 2019-12-01 03:43:57
I was reading this webpack tutorial: https://webpack.github.io/docs/usage.html It says it bundles the src files and node_modules. If I want to add another .js file there, how can I do this? This is a thirdpartyjs file that is not part of the source and not part of the node_modules files. This is my current webpack.config.js: var path = require('path'); var webpack = require('webpack'); module.exports = { entry: [ 'react-hot-loader/patch', 'webpack-dev-server/client?http://localhost:8080', 'webpack/hot/only-dev-server', './app/app.js' ], output: { path: path.resolve(__dirname, "dist"),

react & web pack hot loader. “waiting for roots to load…to reload the inspector”

房东的猫 提交于 2019-12-01 03:16:47
Just updated react to 0.13.3 and now I get the following message in Chrome react developer tool: "waiting for roots to load...to reload the inspector" and a button saying "click here". And if I click the button, same thing again. FYI: I am using WebPack & webpack-dev-server. Have you seen this? This error is generally linked to modules not loading into the project correctly, but the cause of this when the react syntax is incorrect. Generally, it's a missing semicolon after return statements (easy to miss). I've confirmed this using reacts tutorial , writing it out myself, seeing this error,

react & web pack hot loader. “waiting for roots to load…to reload the inspector”

核能气质少年 提交于 2019-11-30 23:32:31
问题 Just updated react to 0.13.3 and now I get the following message in Chrome react developer tool: "waiting for roots to load...to reload the inspector" and a button saying "click here". And if I click the button, same thing again. FYI: I am using WebPack & webpack-dev-server. Have you seen this? 回答1: This error is generally linked to modules not loading into the project correctly, but the cause of this when the react syntax is incorrect. Generally, it's a missing semicolon after return

Webpack dev server throws error - Refused to execute script because its MIME type ('text/html') is not executable

廉价感情. 提交于 2019-11-30 23:10:33
问题 I use Webpack bundler and Webpack dev server for local development. The front-end is in React.js+Redux and the back-end in Node.js and koajs. In back-end, I use passportjs library for user authentication and other libraries koa-passport, passport-facebook, passport-google-auth for authentication through Facebook or Google. Basically, I implemented koa-passport-example. If my application wants to redirect user to Facebook or Google login page, Webpack dev server throws error: GET http:/

Webpack Error - Cannot Resolve File or Directory

一个人想着一个人 提交于 2019-11-30 22:53:07
问题 I am getting this error when I npm start my webpack-dev-server: ERROR in multi main Module not found: Error: Cannot resolve 'file' or 'directory' /var/www/html/151208-DressingAphrodite/app in /var/www/html/151208-DressingAphrodite @ multi main Here is my webpack.config.js: var path = require('path'); var webpack = require('webpack'); var HtmlWebpackPlugin = require ('html-webpack-plugin'); const PATHS = { app: path.join (__dirname, 'app'), build : path.join (__dirname, 'build') }; module

webpack4.41.0配置四(热替换)

放肆的年华 提交于 2019-11-30 21:39:57
每次修改都要去编译,这个操作比较繁琐。所以我们希望编译过程是自动化的,而且页面的更新也是自动化的 。所以需要使用这个热替换 1.首先安装 webpack-dev-server : npm install webpack-dev-server -D (-D生产环境下) (作用为:启动服务并且能够支持热替换) 2.更改一下我们的配置文件 3.启动webpack-dev-server 因为我们没有全局安装webpack-dev-server,所以不能在终端输入webpack-dev-server去启动,我们需要去package.json中创建命令 之所以这个方式可以,是因为它们 查找的方式不一样 ,它会先去mode_modules文件夹中寻找webpack-dev-server。在终端直接输入webpack-dev-server会去path路径中去找。 执行 npm run start 启动之后可以去浏览器中输入localhost:8080访问页面 然后可以在template.html中修改页面内容,即可得到立即更新 4.添加热替换功能 然后重新 npm run start ,现在就是具备热替换功能的服务器了 当hotOnly:false时,我们在页面进行了更改只需要保存,不需要进行页面更新就可以得到修改过后的数据 所以说 这是一个坑 ,我们可以 把hotOnly在配置中去掉

VUE启动流程

别来无恙 提交于 2019-11-30 18:28:35
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-bundle

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

风流意气都作罢 提交于 2019-11-30 18:23:51
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'; import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core';

How to configure webpack dev server with react router dom v4?

可紊 提交于 2019-11-30 17:05:21
This is the code of my webpack configuration: const compiler = webpack({ entry: ['whatwg-fetch', path.resolve(__dirname, 'js', 'app.js')], module: { loaders: [ { exclude: /node_modules/, test: /\.js$/, loader: 'babel', }, ], }, output: {filename: 'app.js', path: '/'}, }); const app = new WebpackDevServer(compiler, { contentBase: '/public/', proxy: {'/graphql': `http://localhost:${GRAPHQL_PORT}`}, publicPath: '/js/', stats: {colors: true}, }); app.use('/', express.static(path.resolve(__dirname, 'public'))); Works fine, the app runs on localhost:3000/index.html but when I try to implement React

Serving static assets in webpack dev server

隐身守侯 提交于 2019-11-30 12:02:07
问题 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