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

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

怎么回事???有點(diǎn)煩躁啊,打包能成功就是會(huì)提示錯(cuò)誤,看著很不爽?。?/h1>

怎么回事???有點(diǎn)煩躁啊,打包能成功就是會(huì)提示錯(cuò)誤,看著很不爽?。?/p>

這是報(bào)錯(cuò)的信息:

ERROR in ./src/components/layer/layer.html

Module parse failed: D:\webpack-app\src\components\layer\layer.html

oken (1:0)

You may need an appropriate loader to handle this file type.

| <div class="layer">

| ? ? <div> this is layer </div>

| </div>

?@ ./src/components/layer/layer.js 7:13-36

?@ ./src/app.js

下面是我的配置:

var htmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
? ?entry:'./src/app.js',
? ?output:{
? ? ? ?path:__dirname+'/dist',//如果想要index文件和js文件分開,可以在此只寫index的路徑,在filename中加上js/即可
? ? ? ?filename:'js/[name].bundle.js',
? ?},
? ?module: {
? ? ? ?rules: [
? ? ? ? ? ?{
? ? ? ? ? ? ? ?test: /\.js$/,
? ? ? ? ? ? ? ?use: {
? ? ? ? ? ? ? ? ? ?loader: 'babel-loader',
? ? ? ? ? ? ? ? ? ?options: {
? ? ? ? ? ? ? ? ? ? ? ?presets: 'env'
? ? ? ? ? ? ? ? ? ?}
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}]
? ?},
? ?plugins:[
? ? ? ?new htmlWebpackPlugin({
? ? ? ? ? ?filename:'index.html',
? ? ? ? ? ?template:'index.html',
? ? ? ? ? ?inject:'body'
? ? ? ?}),
? ?]
}

layer.html 文件:

<div class="layer">
? ?<div> this is layer </div>
</div>

layer.js:

import tpl from './layer.html';
function layer(){
? ?return {
? ? ? ?name:"layer",
? ? ? ?tpl:tpl
? ?}
}
export default layer;

layer.less:

.layer{
?width: 600px;
?height:200px;
?background-color: pink;
? > div{
? ?width: 400px;
? ?height:200px;
? ? background-color: yellowgreen;
?}
}

app.js:

import layer from './components/layer/layer.js';
const App = function App() {
console.log(layer);
}
new App();

package.json:

{
?"name": "webpack-app",
?"version": "1.0.0",
?"description": "",
?"main": "index.js",
?"babel": {
? ?"presets": [
? ? ?"env"
? ?]
?},
?"scripts": {
? ?"test": "echo \"Error: no test specified\" && exit 1",
? ?"webpack": "webpack --config webpack.config.js --progress --colors --display-modules --display-reasons "
?},
?"author": "",
?"license": "ISC",
?"devDependencies": {
? ?"babel-core": "^6.25.0",
? ?"babel-loader": "^7.1.1",
? ?"babel-preset-env": "^1.5.2",
? ?"babel-preset-latest": "^6.24.1",
? ?"html-webpack-plugin": "^2.29.0",
? ?"webpack": "^3.0.0"
?},
?"dependencies": {
? ?"css-loader": "^0.28.4",
? ?"sass-loader": "^6.0.6",
? ?"style-loader": "^0.18.2",
? ?"url-loader": "^0.5.9"
?}
}


正在回答

3 回答

html-webpack-plugin 是一個(gè)插件,主要用來生成html文件,You may need an appropriate loader, 你需要的是一個(gè) loader, 插件是插件,loader是loader,它們兩個(gè)不是一個(gè)東西,webpack 有四個(gè)基本的概念: entry output, loader, plugin. loader 是來解析文件,像css-loader, style-loader, ?babel-loader。 plugin,只是在loader ?對整個(gè)文件解析完成后,做一些其他的事性,如css js 壓縮 等。?

0 回復(fù) 有任何疑惑可以回復(fù)我~

安裝?npm install --save-dev html-loader

http://img1.sycdn.imooc.com//5aa8e50f000184c206360642.jpg

0 回復(fù) 有任何疑惑可以回復(fù)我~

缺少 ejs-loader 吧,?

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

不完美 提問者

提示的是module parse failed ....../layer.html 應(yīng)該是html文件沒有解析,但是我已經(jīng)安裝了html-webpack-plugin了,真不知道哪里出問題了!
2017-07-03 回復(fù) 有任何疑惑可以回復(fù)我~
#2

Y丶John4082919 回復(fù) 不完美 提問者

請問你的問題 解決了嗎?我的也是報(bào)錯(cuò): ERROR in ./src/components/layer/layer.html Module parse failed: D:\BaiduNetdiskDownload\code\works\webpack\src\components\layer\layer.html Unexpected token (1:0) You may need an appropriate loader to handle this file type.
2017-07-04 回復(fù) 有任何疑惑可以回復(fù)我~
#3

不完美 提問者 回復(fù) Y丶John4082919

恩恩,解決了,安裝html-loader npm i -D html-loader 在配置文件里面加上html文件的加載器html-loader就行了,跟js一樣test:/\.html$/,use:{loader:html-loader}
2017-07-04 回復(fù) 有任何疑惑可以回復(fù)我~
#4

Y丶John4082919 回復(fù) 不完美 提問者

O(∩_∩)O謝謝
2017-07-04 回復(fù) 有任何疑惑可以回復(fù)我~
#5

慕圣334673 回復(fù) 不完美 提問者

真贊?。?!
2019-12-02 回復(fù) 有任何疑惑可以回復(fù)我~
查看2條回復(fù)

舉報(bào)

0/150
提交
取消

怎么回事啊?有點(diǎn)煩躁啊,打包能成功就是會(huì)提示錯(cuò)誤,看著很不爽??!

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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