Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.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 无法解码lambda生产应用程序上下载的字体_Angular_Amazon Web Services_Webpack_Aws Lambda_Serverless Framework - Fatal编程技术网

Angular 无法解码lambda生产应用程序上下载的字体

Angular 无法解码lambda生产应用程序上下载的字体,angular,amazon-web-services,webpack,aws-lambda,serverless-framework,Angular,Amazon Web Services,Webpack,Aws Lambda,Serverless Framework,我正在尝试使用无服务器模块将angular web应用程序部署到amazon lambda。当我在本地运行应用程序时,一切正常。当我将应用程序部署到AWS时,问题出现了。部署应用程序后,应用程序工作正常,但某些字体似乎丢失,无法正确显示。以下是Chrome开发者控制台中出现的警告: Failed to decode downloaded font: <URL> OTS parsing error: Size of decompressed WOFF 2.0 is less than

我正在尝试使用无服务器模块将angular web应用程序部署到amazon lambda。当我在本地运行应用程序时,一切正常。当我将应用程序部署到AWS时,问题出现了。部署应用程序后,应用程序工作正常,但某些字体似乎丢失,无法正确显示。以下是Chrome开发者控制台中出现的警告:

Failed to decode downloaded font: <URL>
OTS parsing error: Size of decompressed WOFF 2.0 is less than compressed     size
OTS parsing error: incorrect entrySelector for table directory
OTS parsing error: incorrect file size in WOFF header
OTS parsing error: incorrect entrySelector for table directory
Intuiton告诉我webpack有问题。下面是webpack.server.config.js:

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: {
    server: './server.ts',
  },
  target: 'node',
  resolve: { extensions: ['.ts', '.js'] },
  externals: [/(node_modules|main\..*\.js)/,],
  output: {
    libraryTarget: 'commonjs2',
      path: path.join(__dirname, 'dist/'),
    filename: '[name].js'
  },
  resolve: {
    modules: [
      /* assuming that one up is where your node_modules sit,
         relative to the currently executing script
      */
      path.join(__dirname, '/node_modules')
    ]
  },
  module: {
    rules: [
      { test: /\.ts$/, loader: 'ts-loader' }
    ]
  },
  optimization: {
    minimize: false
  },
  plugins: [
    new webpack.ContextReplacementPlugin(
      // fixes WARNING Critical dependency: the request of a dependency is an expression
      /(.+)?angular(\\|\/)core(.+)?/,
      path.join(__dirname, 'src'), // location of your src
      {} // a map of your routes
    ),
    new webpack.ContextReplacementPlugin(
      // fixes WARNING Critical dependency: the request of a dependency is an expression
      /(.+)?express(\\|\/)(.+)?/,
      path.join(__dirname, 'src'),
      {}
    )
  ]
}

非常感谢您的帮助:)

您需要为这些字体提供适当的浏览器支持:

@font-face {
    font-display: swap;
    font-family: 'YourFontFamilyName';
    /* IE9 Compat Modes */
    src: url('/path/to/yourfont.eot');
    /* IE6-IE8 */
    src: url('/path/to/yourfont.eot?#iefix') format('embedded-opentype'),
        /* Super Modern Browsers */ url('/path/to/yourfont.woff2') format('woff2'),
        /* Pretty Modern Browsers */ url('/path/to/yourfont.woff') format('woff'),
        /* Safari, Android, iOS */ url('/path/to/yourfont.ttf') format('truetype'),
        /* Legacy iOS */ url('/path/to/yourfont.svg#svgFontName') format('svg');
    font-weight: normal;
    font-style: normal;
}
另外,在lambda函数中,将
'application/x-font-ttf'
行替换为以下内容:

'font/ttf',
'font/woff',
'font/woff2'

干杯

我已经找到了解决办法。它与我正在使用的angular应用程序的模板有关。我只是按照他们在文档中的建议注册了图标包,这就成功了。非常感谢您的帮助!:)
'font/ttf',
'font/woff',
'font/woff2'