0
我把Webpack教程從Angular.io並開始升級到的WebPack 2官方和not official指南以下。爲什麼CSS-裝載機/風格裝載機拋出意外的字符#錯誤?
我遇到了以下錯誤:
ERROR在./public/css/styles.css 模塊解析失敗:DashboardDelivery.Host.Ui.Spa \公用\ CSS \ styles.css的意外 字符「#」(3:16) 您可能需要適當的加載程序來處理此類文件。 |身體 | { |背景:#0147A7; |顏色:#fff; | }
- 我不明白是什麼問題
- 如果文件爲空,然後它拋出一個錯誤的位置text.Foreach功能未知
- 如果只有一個空的身體{}在CSS文件然後webpack抱怨身體沒有定義
基本上,無論我在那裏做什麼總是一個問題和相關的字符是最奇怪的。我在這裏錯過了什麼?
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;
}