首页 > 代码库 > 关于web-dev-server 记录

关于web-dev-server 记录

package.json

"scripts": {    "init": "webpack --progress --config webpack.dev.config.js",    "dev": "webpack-dev-server --inline --hot --compress --history-api-fallback --config webpack.dev.config.js",    "build": "webpack --progress --hide-modules --config webpack.prod.config.js"},

 

 

 

 server.js —— 类似express构建http服务

‘use strict‘var webpack = require(‘webpack‘);var WebpackDevServer = require(‘webpack-dev-server‘);var config = require(‘./webpack.config‘);config.entry.unshift(‘webpack-dev-server/client?http://localhost:8090‘, "webpack/hot/dev-server");config.plugins.push(new webpack.HotModuleReplacementPlugin());// 这里配置:请求http://localhost:9090/api,// 相当于通过本地node服务代理请求到了http://cnodejs.org/apivar proxy = [{        target: "https://cnodejs.org",    host: "cnodejs.org",    path: "/api/*"}]//启动服务var app = new WebpackDevServer(webpack(config), {    publicPath: config.output.publicPath,    hot:true,    historyApiFallback: true,    proxy:proxy});app.listen(8090);

 

关于web-dev-server 记录