webpack-dev-server

webpack-dev-server Cannot find module 'webpack'

筅森魡賤 提交于 2019-11-29 22:10:27
I'm trying to use webpack-dev-server to run a simple program but I'm getting this error: module.js:471 throw err; ^ Error: Cannot find module 'webpack' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) I have installed webpack with following npm

Proxy requests to a separate backend server with vue-cli

妖精的绣舞 提交于 2019-11-29 21:33:58
I am using vue-cli webpack-simple template to generate my projects, and I'd like to proxy requests to a separate, backend server. How can this be easily achieved? Mani If you use webpack template with vue-cli , then you can find the required information in this reference document: http://vuejs-templates.github.io/webpack/proxy.html Or instead of changing your template now, you may copy the relevant config from the webpack template into your local webpack-simple template. EDIT: more info from my local setup This is what I have in my config/index.js under module.exports : dev: { env: require('.

Webpack: silence output

倾然丶 夕夏残阳落幕 提交于 2019-11-29 21:17:31
I would like to know if there's a configuration option to tell webpack to only log the "important information" to the terminal. Pretty much just errors and warnings, not all of this: There's just so much output! Would love to suppress the common stuff and only have webpack output the warnings/errors. Would like a solution for webpack , webpack-dev-server , and karma-webpack . Note : I tried noInfo: true and quiet: true but that didn't seem to do the trick. Edit: I'm thinking this may not be possible, so I've created an issue on github: https://github.com/webpack/webpack/issues/1191 In my

Webpack-dev-server compiles files but does not refresh or make compiled javascript available to browser

偶尔善良 提交于 2019-11-29 21:12:16
I'm trying to use webpack-dev-server to compile files and start up a dev web server. In my package.json I have the script property set to: "scripts": { "dev": "webpack-dev-server --hot --inline", } So the --hot and --inline should enable the webserver and the hot reloading (as I understand it). In my webpack.config.js file I set the entry, output, and devServer settings as well as add a loader to look for changes in .vue files: module.exports = { entry: './src/index.js', output: { path: __dirname + '/public', publicPath: '/public', filename: 'bundle.js' }, devtool: 'source-map', devServer:{

Error `window not defined` in Node.js

那年仲夏 提交于 2019-11-29 17:37:22
问题 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) ? 回答1: 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

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

丶灬走出姿态 提交于 2019-11-29 16:14:35
问题 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

Can't get Webpack 2 HMR React to work

不问归期 提交于 2019-11-29 15:14:35
Currently I'm struggling to get HMR working in my Webpack 2 setup. I'll explain my entire setup so I hope this is enough for someone to understand what's happening. The structure of my project: config dev.js prod.js dist css js index.html node_modules src components // some JavaScript components shared stylesheets index.js .babelrc package.json webpack.config.js This are the contents of my webpack.config.js file, placed in the root of my project: function buildConfig(env) { return require('./config/' + env + '.js')(env) } module.exports = buildConfig; So in this file I've the option to pass

How to watch certain node_modules changes with webpack-dev-server

蓝咒 提交于 2019-11-29 13:29:40
问题 I'm currently experimenting with a monorepo architecture. What I would like to do is in my web package where I run webpack dev server I'd like it to watch certain node_modules (symlinked local packages) for changes and trigger a "rebuild". This way I'd be able to build dependencies separately and my browser would react to those changes. My webpack config is the following: var loaders = require('./../../../build/loaders-default'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var

How to use webpack-dev-server multiple entries point

为君一笑 提交于 2019-11-29 11:31:55
问题 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

webpack学习笔记(四) 自动编译

瘦欲@ 提交于 2019-11-29 08:30:00
我们每次修改代码之后,如果想要在浏览器中看到变化,都先要手动编译代码,这样未免有些麻烦 在 webpack 中,配置某些选项可以帮助我们在代码发生变化之后自动编译代码 1、存在问题 首先我们搭建一个简单的项目,感受一下在不使用自动编译之前项目开发的状态 创建一个空文件夹 Demo ,作为项目的根目录,在该目录下运行如下命令安装项目所需依赖 > # 创建 package.json 文件 > npm init -y > # 安装 webpack > npm install --save-dev webpack > npm install --save-dev webpack-cli > # 安装 lodash > npm install --save lodash 然后我们在根目录下创建 dist 和 src 目录,并在相应的目录下创建相应的文件,最终的目录结构如下 Demo - package.json - package-lock.json - webpack.config.js + node_modules + src - index.js + dist - index.html webpack.config.js 文件内容,指定 webpack 的一些基本配置 const path = require('path'); module.exports = { entry: '.