在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ webpack4打包出錯

webpack4打包出錯

webpack.conf.js

const path = require('path');  
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); 
const uglify = require('uglifyjs-webpack-plugin'); 
module.exports={  
    //入口配置  
    entry:{  
        a:'./src/index.js',  
        b:'./src/index2.js'  
    },  
    //出口配置  
    output:{  
        path:path.resolve(__dirname,'dist'),//path必須是絕對路徑  
        filename:'[name].bundle.js',
        publicPath: '/'
    },  
    module: {
        rules:[
           {
                test:/\.css$/,
                use:['style-loader','css-loader'],
                include:path.join(__dirname,'./src'),
                exclude:/node_modules/
           },{
                test: /\.(png|jpg|gif|svg|bmp|eot|woff|woff2|ttf)$/,
                loader: {
                    loader: 'url-loader',
                    options: {
                        limit: 5 * 1024,// 圖片大小 > limit 使用file-loader, 反之使用url-loader
                        outputPath: 'images/'// 指定打包后的圖片位置
                    }
                }
            }   
        ]
    },
    plugins:[  
        new webpack.HotModuleReplacementPlugin(),
        new HtmlWebpackPlugin({  
            chunks:["a"],  
            filename:'index.html',//默認是index.html  
            template:"./src/index.html"  
        }),  
        // new uglify() 
    ],
    devServer:{  
        contentBase:path.resolve(__dirname,'dist'),  
        host:'localhost',  
        port:8090,  
        open:true,
        compress: true // 服務(wù)器返回瀏覽器的時候是否啟動gzip壓縮
 
    } 
};  

./src/index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" type="text/css" href="./css/index.css">
</head>
<body>
  <div id="app"></div>
  <h1>wejiweji</h1>
  <div id="tupian"></div>
</body>
</html>

瀏覽器報錯
圖片描述

index.css
#tupian{
    background-image: url(../imagess/a.png);
    width:466px;
    height:453px;
 }

求大佬解答

回答
編輯回答
撥弦
  1. refused to apply style,被拒絕使用了; 應(yīng)該是靜態(tài)資源不能使用問題;
  2. 利用 Express 托管靜態(tài)文件
2017年10月22日 20:32
編輯回答
護她命

你這個 index.html 都沒有把 js 引入進來。css 自然就加載不進來了

2017年12月12日 18:05