webpack-dev-server

webpack4.0-devServer的使用-04

拜拜、爱过 提交于 2019-12-20 20:19:56
修改文件后自动打包配置(监听源代码变动打包) 第一种方法: package.json文件配置scripts "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "bundle": "webpack", "watch": "webpack --watch" // 监听源代码变动,自动打包 }, 第二种方法: 通过webpack的devServer实现监听打包,安装webpack-dev-server // webpack.config.js中的配置 devServer: { contentBase: './dist', // 定义服务器启动服务的位置 open: true , // 启动webpack devServer的时候自动打开浏览器 proxy: { // 用于跨域配置 }, port: 8089, // 定义服务的端口号 } package.json中的配置 "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "bundle": "webpack", "server": "webpack-dev-server" // webpack-dev-server启动本地服务 }, 来源: CSDN 作者:

Webpack SASS loader cannot dedupe common SCSS imports

久未见 提交于 2019-12-20 19:45:07
问题 I have the following structure: node_modules - my_component - font - scss - my_component.scss src - my_app.js - my_app.scss I'm trying to import the styles in my_component.scss . This file contains @font-face declarations with references to ../font/ . So something like: // my_component.scss @font-face { font-family: 'Helvetica Neue'; font-weight: $weight-medium; src: url('../font/font-file.eot'); } In my_app.js I'm requiring the SCSS file associated with it. So // my_app.js require('./my_app

“Invalid Host Header” in When running React App

萝らか妹 提交于 2019-12-20 18:35:18
问题 I am having one simple project of React JS and I am deploying into OSE. Also I am using below dependencies in my project. "webpack": "^2.2.0", "webpack-dev-server": "^1.14.1", "react": "^15.5.4", "react-router-dom": "^4.1.1" also I am running my project through below build script. "build": "SET NODE_ENV=production && webpack-dev-server --host 0.0.0.0 --inline --history-api-fallback --content-base . " Everything goes fine in OSE and Webpack is compiled successfully. But on accessing the url it

webpack-dev-server rebuild with ejs

一曲冷凌霜 提交于 2019-12-20 10:44:12
问题 I'm using webpack-dev-server with this config: import webpack from 'webpack'; import autoprefixer from 'autoprefixer'; import ExtractTextPlugin from 'extract-text-webpack-plugin'; import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin'; import HtmlWebpackPlugin from 'html-webpack-plugin'; const exports = { devtool: 'cheap-module-source-map', entry: { bundle: `${__dirname}/src/main.ejs`, commons: [ 'lodash', 'webpack-dev-server/client?http://localhost:8090', 'webpack/hot

` __webpack_require__(…) is not a function` when using babel 6

旧巷老猫 提交于 2019-12-20 10:17:56
问题 Everything seems to build fine: http://d.pr/i/1aZxR with the following configs. However, when I run the code I get the following error this (via webpack-dev-server): Uncaught TypeError: __webpack_require__(...) is not a function(anonymous function) @ login.js:4__webpack_require__ @ bootstrap 38790ff45722f55eb700?6a08:50(anonymous function) @ bootstrap.js:2363__webpack_require__ @ bootstrap 38790ff45722f55eb700?6a08:50(anonymous function) @ app.38790ff45722f55eb700.js:29__webpack_require__ @

html-webpack-plugin not inject js file into index.html when using webpack-dev-server

社会主义新天地 提交于 2019-12-20 10:10:22
问题 Here is my webpack config : var path = require('path'); var webpack = require('webpack') var HtmlWebpackPlugin = require('html-webpack-plugin') var fs = require('fs'),buildPath='./dist/'; var folder_exists = fs.existsSync(buildPath); if(folder_exists == true) { require('shelljs/global') rm('-rf', 'dist') }; module.exports = { entry: './src/main', output: { path: path.join(__dirname, './dist'), filename: '[name].js', publicPath: '/dist/' }, devServer: { historyApiFallback: true, hot: false,

Webpack-dev-server serves a directory list instead of the app page

╄→гoц情女王★ 提交于 2019-12-20 08:27:11
问题 I can only see the actual app under /public . The configs in webpack.config.js are below: var path = require('path'); var webpack = require('webpack'); module.exports = { entry: [ 'webpack-dev-server/client?http://localhost:8080', 'webpack/hot/only-dev-server', './app/js/App.js' ], output: { path: path.join(__dirname, 'public'), filename: 'bundle.js', publicPath: 'http://localhost:8080' }, module: { loaders: [ { test: /\.js$/, loaders: ['react-hot', 'babel-loader'], exclude: /node_modules/ }

Webpack development server seperate subdomain proxied by nginx

帅比萌擦擦* 提交于 2019-12-20 07:26:48
问题 im currently stuck on a probem with the webpack-dev-server which listen on a wrong domain with a wromng port. I've dockerized my Symfony application having 3 container, node, php and nginx. On the Node container the webpack-dev-server is running with the following (shortened) configuration output: { filename: '[name].[hash].js', chunkFilename: '[name].[chunkhash].js', path: Path.resolve(__dirname, 'web/static'), publicPath: '/static/' }, devServer: { contentBase: Path.join(__dirname, 'web'),

Webpack There are multiple modules with names that only differ in casing

天大地大妈咪最大 提交于 2019-12-20 04:19:04
问题 I have something like this: WARNING in C:/Data/.../letsTest.jsx There are multiple modules with names that only differ in casing. This can lead to unexpected behavior when compiling on a filesystem with other case-semantic. Use equal casing. Compare these module identifiers: * C:\Data\...\node_modules\babel-loader\lib\index.js?presets[]=es2015&presets[]=react&presets[]=stage-0&presets[]=stage-2!C:\Data\...\letsTest.jsx Used by 4 module(s), i. e. multi C:/Data/Doc/13/13080801/LetsTest/letsTest

不使用 vue-cli 去搭建一个 vue + webpack 的准备项目 (配置详解)(三)webpack配置devServer,详细说明原理。

帅比萌擦擦* 提交于 2019-12-20 00:43:57
四、配置webpack-dev-server (1) 理解为什么要使用 webpack-dev-server 在上面一篇文章中,我们已经可以通过webpack去打包整个项目了,但是每次写完代码,都需要手动运行一下webpack执行打包,才能看到修改后的效果,这对于我们前端开发来说是十分不方便的。还有一点就是如果我们想发送一个ajax请求,那么必须要使用http协议,而直接打开本地文件使用的则是file协议。因此,我们可以使用webpack自带的devServer来在前端开启一个小型服务器,这个服务器可以监听我们的文件改动然后自动刷新页面,可以帮助我们实现ajax请求的发送。 我们在第一篇文章的开头就已经安装好了 webpack-dev-server 因此我们可以直接进入webpack.config.js去开启他! (2)配置webpack-dev-server 在module.exports中增加如下配置: devServer: { open: true, // 开启服务器后是否自动打开浏览器 port: 9090, // 服务器所占端口 contentBase: path.resolve(__dirname, 'dist'), // 服务器打开本地文件的地址 hot: true, historyApiFallback: true,//找不到页面默认跳index.html },