webpack-dev-server

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

徘徊边缘 提交于 2019-12-02 21:14:38
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, inline: true, grogress: true, }, // "vue-hot-reload-api": "^1.2.2", module: { loaders: [ { test: /\.vue$/

Unexpected token Module build failed: SyntaxError

自古美人都是妖i 提交于 2019-12-02 19:42:42
问题 I porting GiftedMessager 1: https://github.com/FaridSafi/react-native-gifted-messenger on web. I able to resolved previous problem Now i stuck in new problem, i'm not able to port react-native-parsed-text . Error i found on terminal window is [684] ./~/react-native-communications/AKCommunications.js 5.16 kB {0} [built] ERROR in ./~/react-native-parsed-text/src/ParsedText.js Module build failed: SyntaxError: /Users/Gaurav/WebWork/ReactWeb/Practise/react-native-web-exploding-hearts-master/node

Customise ng serve to proxy calls to /api?

心不动则不痛 提交于 2019-12-02 18:57:30
I created a new application with ng CLI, works like a charm: ng new babysteps cd babysteps ng serve ng serve uses webpack to assemble the app. To fully test it, I need to serve /api... from my API mock server (specifically the POST requests). How can I customise the web server used, to redirect that one URL pattern? The Webpack dev server has a proxy setting , but it seems (?) ng serve doesn't have a config file (or I didn't get). Do I need to create a webpack.config.js or create/edit some other file to proxy ? Fredrik Lundin You can indeed setup a proxy to backend with the angular cli, with

Change hard coded url constants for different environments via webpack

孤街浪徒 提交于 2019-12-02 18:54:50
I have a ApiCaller.js module which generate calls to our api server to get data. It has const field API_URL which points to server url. This API_URL const changes for dev and prod environments. So when I need to deploy to dev environment I need to change that url ( API_URL ) manually to point to dev-api-server and vice-versa. I want these configuration parameters outside the code and during build process I want to change them dynamically so that I can build with different settings. I am using webpack to bundle my javascript, html, css files. You can store your API_URL in webpack config: //

webpack config to use plugin and webpack-dev-server

拟墨画扇 提交于 2019-12-02 18:46:56
Demo3操作手册 本Demo演示如何配合各种plugin进行偏复杂的使用 准备环境 初始化环境, cd到demo1目录之后, 执行如下命令: npm init -y npm install webpack webpack-cli -D 继续使用上一个level的目录机构以及环境: npm install typescript ts-loader node-sass sass-loader css-loader style-loader -D 新建tsconfig.json, 内容如下: { "compilerOptions": { "target": "es5" } } L4 UglifyjsWebpackPlugin 顾名思义, 该插件是用来对js进行丑化处理, 使其难以阅读以提升代码的安全性, 安装该插件: npm install uglifyjs-webpack-plugin -D 新建src目录并且新建如下三个文件: <!-- index.html --> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Webpack</title> </head> <body> <button class="red" id="btn">HAHAHA</button> </body> </html> //

webpack-dev-server error on npm start

浪子不回头ぞ 提交于 2019-12-02 18:46:33
问题 I am trying to run npm start on ng2-admin,all was working untill I did npm update to try to update the pacakages, after that did npm start and have an error: webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/ 10% building modules 3/3 modules 0 activeError: listen EADDRINUSE 127.0.0.1:8080 at Object.exports._errnoException (util.js:1026:11) at exports._exceptionWithHostPort (util.js:1049:20) at Server._listen2 (net.js:1257:14) at listen (net.js

webpack---less 热更新 使用

时间秒杀一切 提交于 2019-12-02 15:21:45
  最近尝试用less写界面,webpack进行打包,然后发现每次修改less时都需要重新执行webpack打包一下,于是就想到了webpack热更新这个功能。 一、使用less   less是一门css预处理语言,它是拓展了css,增加了变量,Mixin等等。使用less需要安装less服务,less-loader用来打包时用,想要将less正确解析成css当然还需要style-loader和css-loader。loader是webpack重要的功能之一,通过使用不同的loader,webpack可以使用外部脚本或工具处理不同格式类型的文件,如通过less-loader处".less"文件。 首先安装: npm install less --save-dev npm install style-loader css-loader less-loader --save-dev webpack.config.js配置: module: { rules: [{ test: /\.less$/ , use: [ 'style-loader', 'css-loader', 'less-loader' ] }] } 然后将.less文件加载到入口文件里,如在入口文件里import '../less/topHead.less';这样就可以执行webpack把.less文件进行打包了。 二

Webpack watch not working on Webstorm on Windows?

梦想与她 提交于 2019-12-02 14:09:33
So basically I have a project using Webpack, if I build using Webpack -w , editing the file with another editor will trigger the watch; however if I edit the file using Webstorm, nothing will happen. I have came across this post , which seems I'm not the only one, however that solution is for Ubuntu, so I was wondering if there is anything similar for Windows? Thanks seems Webpack watch doesn't work if the file is not saved directly. Please try turning ' Safe write ' option ( Settings | Appearance & Behavior | System Settings | Use "safe write" (save changes to temporary file first) ) off Also

Webpack 4.X 从入门到精通 - devServer与mode(三)

柔情痞子 提交于 2019-12-02 14:01:12
上一篇文章 里详细介绍了一下插件的用法,这一篇文章接着丰富 module.exports 里的属性。如今的前端发展已经非常迅速了,伴随而来的是开发模式的转变。现在已经不再是写个静态页面并放在浏览器里打开预览一下了。在实际的开发中会经常需要使用 http 服务器,比如之前的 ajax ,想要看到效果就必需搭建一个服务器。搭建服务器的方式有非常的多,而 webpack 则原生的提供服务器的支持,大家无需再去下载软件。同时它还提供了自动刷新、热更新等功能,使开发变得非常方便。 devServer 安装使用 npm i webpack-dev-server -D 打开终端,并进入到对应的项目里(我的为 webpack-demo ),执行命令 webpack-dev-server ,如果终端里显示如下则表示已经成功开启服务器 注意: 1、此时可能会提示 webpack-dev-server 不是内部命令,解决办法为在全局再次安装一下 webpack-dev-server 模块,或者在 package.json 里的 scripts 里加上 "dev": "webpack-dev-server" ,然后执行命令 npm run dev 2、此时我并没有通过 webpack 命令生成一个 dist 目录(目录结构如下图),然后在浏览器里输入地址 http://localhost:8080/ 后

Webpack configuration file found but no entry configured

懵懂的女人 提交于 2019-12-02 10:49:54
Im trying to organize a webpack 2 template for my personal projects with webpack-dev-server and run it with the npm commands, but i'm getting this error: Configuration file found but no entry configured. It's weird because the entry is defined and i tested the resolved route, it's fine, so here is my webpack config, the command to run it and the file to configure the loaders: webpack.config.dev.js const path = require('path'); const fs = require('fs'); const configs = require('./dev-wpk-conf'); const HtmlPlugin = require('html-webpack-plugin'); const Dotenv = require('dotenv-webpack'); const