在dist文件夹中没有发出CSS文件

时间:2017-07-27 19:27:42

标签: webpack

这是我的webpack.config文件。我正在尝试将bundle.css作为单独的文件注入到html.js文件中,而index.html正在dist文件夹中发出,但css文件没有运气。< / p>

EDITED: 我不希望我的捆绑的js,css文件添加到html或需要通过js.I希望它被注入。现在脚本文件自动注入到html文件,我希望css文件发生同样的事情。

的index.html

<!DOCTYPE html>
<html>
<head>
<title>Digital</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/digi">
</head>
<body ng-app='app'>
<div ui-view></div>
</body>
</html>

webpack配置文件

var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
    entry: {
        app: './app/boot.js'
    },
    output: {
        path: path.resolve(__dirname) + '/dist',   
        filename: 'bundle.js'
    }, 
    devtool: 'source-map',                         
    devServer: {
        contentBase: path.resolve(__dirname),
        port: 9097
    },
    module: {
        loaders: [
        { 
            test: /\.css$/,
            exclude: /node_modules/,
            loader: ExtractTextPlugin.extract('css?sourceMap')
        },
        {
            test: /\.(png|jpg|ttf|woff)/,
            exclude: /node_modules/,
            loader: "url-loader?limit=10000"
        }
        ]
    },
    plugins: [ 
        new HtmlWebpackPlugin({
            template: 'index.html',
            inject: true
        }),
        new ExtractTextPlugin('bundle.css')
    ],
    resolve: {
    modules: ['./app/appManager/','./node_modules'],
    alias: {
       index: path.resolve(__dirname) + '/app',    
       root: path.resolve(__dirname)
    }
  }
};

0 个答案:

没有答案