Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 使用角度+;网页包_Angular_Webpack - Fatal编程技术网

Angular 使用角度+;网页包

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

当使用Angular+webpack时,我在网页上显示图像时遇到问题。我不知道是什么原因,但在web浏览器中,“img”标记(“”)的英文括号被转义符号(“”)取代

myComponent.template.html

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>