我从Angular.io获取了Webpack教程,并在官方和not official指南之后开始升级到Webpack 2。
我遇到了以下错误:
./public/css/styles.css中的错误 模块解析失败:DashboardDelivery.Host.Ui.Spa \ public \ css \ styles.css意外 人物'#' (3:16) 您可能需要适当的加载程序来处理此文件类型。 |体 | { |背景:#0147A7; |颜色:#fff; | }
基本上,无论我做什么都不重要,总有一个问题,而且相关的角色最奇怪。我在这里失踪了什么?
webpack.common.js
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');
module.exports = {
entry: {
'polyfills': './src/app/polyfills.ts',
'vendor': './src/app/vendor.ts',
'app': './src/app/main.ts'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
use: ['awesome-typescript-loader', 'angular2-template-loader']
},
{
test: /\.html$/,
use: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
use: 'file-loader?name=assets/[name].[hash].[ext]'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
use: ExtractTextPlugin.extract(
{
fallbackLoader: 'style-loader',
loader: 'css-loader?sourceMap',
publicPath: "/dist"
})
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
use: 'raw-loader'
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
]
};
webpack.dev.js
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
module.exports = webpackMerge(commonConfig, {
devtool: 'cheap-module-eval-source-map',
output: {
path: helpers.root('dist'),
publicPath: 'http://localhost:8080/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
plugins: [
new ExtractTextPlugin('[name].css')
],
devServer: {
historyApiFallback: true,
stats: 'minimal'
}
});
的style.css
body
{
background: #0147A7;
color: #fff;
}