第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

webpack-dev-server啟動后,頁面無法解析公共模塊頁面

webpack-dev-server啟動后,頁面無法解析公共模塊頁面

rrbaby520 2017-08-30 22:27:57
rosen老師,我用webpack-dev-server啟動后訪問頁面,index.html 頁面引入的公共模塊都無法解析,<!DOCTYPE?html> <html> ????<head>? ????????<%=?require('html-loader!./layout/head-common.html')%> ????????<title><%=?htmlWebpackPlugin.options.title%>?-?happymmall電商平臺</title> ????</head> ????<body> ????????<%=?require('html-loader!./layout/nav.html')??%> ????????<%=?require('html-loader!./layout/header.html')??%> ????????<%=?require('html-loader!./layout/footer.html')??%> ???????? ????</body> </html>在通過webpack打包到dist目錄下后,這些文件是可以被解析的,我的webpack配置是var?webpack?????????????=?require('webpack'); var?ExtractTextPlugin???=?require('extract-text-webpack-plugin'); var?HtmlWebpackPlugin???=?require('html-webpack-plugin'); //?環(huán)境變量配置,dev?/?online var?WEBPACK_ENV?????????=?process.env.WEBPACK_ENV?||?'dev'; //?獲取html-webpack-plugin參數(shù)的方法? var?getHtmlConfig?=?function(name){ ????return?{ ????????template????:?'./src/view/'?+?name?+?'.html', ????????filename????:?'view/'?+?name?+?'.html', ????????//?title???????:?title, ????????inject??????:?true, ????????hash????????:?true, ????????chunks??????:?['common',?name] ????}; }; //?webpack?config var?config?=?{ ????devtool:?'eval-source-map', ????entry:?{ ????????'common'????????????:?['./src/page/common/index.js'], ????????'index'?????????????:?['./src/page/index/index.js'], ????????'user-login'????????:?['./src/page/user-login/index.js'], ??????? ????}, ????output:?{ ????????path:?'./dist', ????????publicPath?:?'/dist', ????????filename:?'js/[name].js' ????}, ????externals?:?{ ????????'jquery'?:?'window.jQuery' ????}, ????module:?{ ????????loaders:?[ ????????????{?test:?/\.css$/,?loader:?ExtractTextPlugin.extract("style-loader","css-loader")?}, ????????????{?test:?/\.(gif|png|jpg|woff|svg|eot|ttf)\??.*$/,?loader:?'url-loader?limit=100&name=/resource/[name].[ext]'?}, ????????????{?test:?/\.string$/,?loader:?'html-loader'} ????????] ????}, ????//?resolve?:?{ ????//?????alias?:?{ ????//?????????node_modules????:?__dirname?+?'/node_modules', ????//?????????util????????????:?__dirname?+?'/src/util', ????//?????????page????????????:?__dirname?+?'/src/page', ????//?????????service?????????:?__dirname?+?'/src/service', ????//?????????image???????????:?__dirname?+?'/src/image' ????//?????} ????//?}, ????plugins:?[ ????????//?獨立通用模塊到j(luò)s/base.js ????????new?webpack.optimize.CommonsChunkPlugin({ ????????????name?:?'common', ????????????filename?:?'js/base.js' ????????}), ????????//?把css單獨打包到文件里 ????????new?ExtractTextPlugin("css/[name].css"), ????????//?html模板的處理 ????????new?HtmlWebpackPlugin(getHtmlConfig('index')), ????????new?HtmlWebpackPlugin(getHtmlConfig('login')), ????] }; if('dev'?===?WEBPACK_ENV){ ????config.entry.common.push('webpack-dev-server/client?http://localhost:8088/'); } module.exports?=?config;packge.json 配置文件是? "dependencies": {? ? "font-awesome": "^4.7.0",? ? "hogan": "^1.0.2",? ? "html-webpack-plugin": "^2.28.0"? },? "devDependencies": {? ? "css-loader": "^0.28.1",? ? "extract-text-webpack-plugin": "^1.0.1",? ? "file-loader": "^0.11.1",? ? "html-loader": "^0.4.5",? ? "style-loader": "^0.17.0",? ? "url-loader": "^0.5.8",? ? "webpack": "^1.15.0",? ? "webpack-dev-server": "^1.16.5"? }麻煩老師看下
查看完整描述

2 回答

?
斯諾克的海

TA貢獻(xiàn)2條經(jīng)驗 獲得超1個贊

請問解決了嗎?改了好久了不行

查看完整回答
反對 回復(fù) 2018-05-06
  • 慕粉3543274
    慕粉3543274
    先打包,localhost 訪問dist目錄下的內(nèi)容,不是src下的內(nèi)容
  • 斯諾克的海
    斯諾克的海
    打包是可以,但是webpack-dev-server的實時預(yù)覽做不到,每次打包很花費時間,請問小伙伴有沒有更好的辦法呢?
  • 斯諾克的海
    斯諾克的海
    正確訪問路徑是:http://localhost:8088/dist/view。之前錯用了路徑:http://localhost:8088/src/view/。希望能幫助后面看到的人!非常感謝美女的回答?。?/div>
?
精慕門5330565

TA貢獻(xiàn)4條經(jīng)驗 獲得超1個贊

你這樣提問題,老師也會蒙圈

查看完整回答
反對 回復(fù) 2017-09-01
  • 2 回答
  • 1 關(guān)注
  • 4292 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號