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

鍍金池/ 問答/HTML/ webpack-dev-server 報(bào) cannot get ?

webpack-dev-server 報(bào) cannot get ?

webpack 配置:

const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");


var getHtmlConfig = function (name, title) {
    return {
        template: './demos/index.html',
        filename: '/demos/' + name + '.html',
        title: title,
        inject: true|'body',
        hash: true,
        cache: true,
        chunks: ['common', name]
    };
};


module.exports = {
    entry: {
        'jxtl': ['./js/jxtl.js']
    },

    devServer: {
        contentBase: './dist',
        hot: true,
        compress: true,
        port: 8000,
        clientLogLevel: "none",
        quiet: true,
      },

    //   模塊解析
    module: {
        loaders: [{
                test: /\.html$/,
                loader: 'html-loader'
            },
            {
                test: /\.css$/,
                loader: 'css-loader!px2rem-loader?remUnit=40&remPrecision=8'
            },
            {
                test: /\.scss$/,
                loader: 'css-loader!px2rem-loader?remUnit=46.875&remPrecision=8!sass-loader'
            },
            {
                test: /\.(png|jpg|gif|jpeg)$/,
                loader: 'url-loader',
                options: {
                    limit: 2048,
                    name: 'images/[name].[ext]'
                }
            },
            {
                test: /\.(eot|svg|ttf|woff|woff2|otf)$/,
                loader: 'url-loader',
                options: {
                    limit: 8192,
                    name: 'fonts/[name].[ext]'
                }
            }
        ]
    },

    //   輸出
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'js/[name].min.js'
    },

    // 插件
    plugins: [
        new HtmlWebpackPlugin(getHtmlConfig('jxtl', 'jxtl'))
    ]
};

命令行信息:
圖片描述

回答
編輯回答
伴謊

contentBase: __dirname + '/dist'改成這樣試試呢?感覺是路徑不對(duì)找不到資源

clipboard.png
這個(gè)位置也改成__dirname + '/dist/demos/'這種路徑呢?

2018年8月15日 05:56
編輯回答
絯孑氣

devServer: {

    contentBase: path.join(__dirname, 'dist'),
    compress: true,
    port: 9000
  },

contentBase的路徑改為這樣成功解決!

2018年7月11日 17:21