1

我在 AOT 模式下有一些警告和错误,在 JIT 模式下没问题。

在 AOT 模式下,应用程序在浏览器中运行良好,但在构建过程中出现警告和错误消息,如下所示:

例如第一个警告:

WARNING in ./~/@swimlane/ngx-charts/release/ngx-charts.module.js
Cannot find source file '../build/ngx-charts.module.ts': Error: Can't resolve '../build/ngx-charts.module.ts' in '/Users/guest/Prive/DevAngular/proto-chartev3-angular/node_modules/@swimlane/ngx-charts/release'
 @ ./aot/src/app/app.module.ngfactory.ts 60:0-70
 @ ./src/main-aot.ts
 @ multi ./src/main-aot

例如第一个错误:

ERROR in ./~/@swimlane/ngx-charts/release/common/base-chart.component.css
    Module build failed: Error: "extract-text-webpack-plugin" loader is used without the corresponding plugin, refer to https://github.com/webpack/extract-text-webpack-plugin for the usage example
        at Object.module.exports.pitch (/Users/guest/Prive/DevAngular/proto-chartev3-angular/node_modules/extract-text-webpack-plugin/loader.js:27:9)

ngx-charts 版本:6.0.1

角度版本:4.2.4

Webpack 版本:2.2.1

我究竟做错了什么?

4

1 回答 1

0

我猜这是您的 webpack 配置的问题。我已经解决了以下 extract-text-webpack-plugin 错误:

// css loader for app styles
    {
      test: /\.css$/,
      exclude: /node_modules/,
      loader: ExtractTextPlugin.extract({
        fallback: 'style-loader',
        use: [
          { loader: 'css-loader', options: { minimize: true } },
        ],
      }),
    },
    // css loader for node_modules to prevent nasty warnings
    {
      test: /\.css$/,
      exclude: path.join(__dirname, 'src/frontend'),
      use: ['raw-loader', 'sass-loader'],
    },

要从 node_modules 中获取所有样式,您需要将它们导入到您的 styles.ts 中:

@import '~@swimlane/ngx-charts/release/index.css';
于 2018-01-26T23:19:32.010 回答