Angular 使用角度+;网页包
当使用Angular+webpack时,我在网页上显示图像时遇到问题。我不知道是什么原因,但在web浏览器中,“img”标记(“”)的英文括号被转义符号(“”)取代 myComponent.template.html:Angular 使用角度+;网页包,angular,webpack,Angular,Webpack,当使用Angular+webpack时,我在网页上显示图像时遇到问题。我不知道是什么原因,但在web浏览器中,“img”标记(“”)的英文括号被转义符号(“”)取代 myComponent.template.html: const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const MiniCssExtractPlugin = require("min
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'app': './src/main.ts'
},
output:{
path: path.resolve(__dirname, '../DearHome.Web/wwwroot'),
publicPath: '/',
filename: '[name].js'
},
devServer: { historyApiFallback: true },
resolve: { extensions: ['.ts', '.js'] },
module: {
rules:[
{
test: /\.ts$/,
use: [ {
loader: 'awesome-typescript-loader',
options: { configFileName: path.resolve(__dirname, 'tsconfig.json') }
},
'angular2-template-loader'
]
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'file-loader?name=assets/[name].[hash].[ext]'
},
{ test: /\.html$/, loader: 'html-loader' },
{ test: /\.(vs|fs)$/, loader: 'raw-loader' },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.scss$/,loaders: ['style', 'css', 'postcss', 'sass'] }
]
},
plugins: [
new webpack.LoaderOptionsPlugin({ debug: true }),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core/,
path.resolve(__dirname, 'src'),
{}
),
new webpack.SourceMapDevToolPlugin(),
new HtmlWebpackPlugin({ template: 'src/index.html' }),
new MiniCssExtractPlugin({ filename: "[name].css" }),
//new UglifyJSPlugin()
]
}
<div> <img src='./Resources/Rotation.png' /> </div>
我不确定哪个加载程序替换尖括号来转义符号,但在我看来,它是文件加载程序
,因为据我所知,正是这个加载程序在输出中创建了资源,并在那里复制了资源,然后他试图找到对图像的所有引用,并将其替换为资源中创建的图像的路径。
但同时,我怀疑angular2模板加载器
,因为据我所知,正是这个加载器通过templateUrl
获取模板文本,并将其传递到组件的template
属性中
不管怎样,我做错了什么
<div> <img src='./Resources/Rotation.png' /> </div>