装载机没有像预期的那样按顺序运行

时间:2017-11-16 11:49:23

标签: angular webpack

我正在尝试先运行webpack-strip-block加载程序,以删除某些依赖项,这些依赖项是由angular进行导入和捆绑的,但出于某种原因,@ ngtools / webpack似乎先运行先于其他任何东西。

从我的理解中,加载器是从底部到顶部运行的,但在这种情况下似乎并非如此。

这是我的配置文件:

"module": {
"rules": [
  {
    "test": /\.html$/,
    "loader": "raw-loader"
  },
  {
    "test": /\.(eot|svg|cur)$/,
    "loader": "file-loader",
    "options": {
      "name": "[name].[hash:20].[ext]",
      "limit": 10000
    }
  },
  {
    "test": /\.(jpg|png|webp|gif|otf|ttf|woff|woff2|ani)$/,
    "loader": "url-loader",
    "options": {
      "name": "[name].[hash:20].[ext]",
      "limit": 10000
    }
  },
  {
    "test": /\.js$/,
    "use": [
      {
        "loader": "@angular-devkit/build-optimizer/webpack-loader",
        "options": {
          "sourceMap": false
        }
      }
    ]
  },
  {
    "exclude": [
      path.join(process.cwd(), "src/assets/stylesheets/styles.scss"),
      path.join(process.cwd(), "src/assets/stylesheets/mobile.scss")
    ],
    "test": /\.scss$|\.sass$/,
    "use": [
      "exports-loader?module.exports.toString()",
      {
        "loader": "css-loader",
        "options": {
          "sourceMap": false,
          "importLoaders": 1
        }
      },
      {
        "loader": "postcss-loader",
        "options": {
          "ident": "postcss",
          "plugins": postcssPlugins
        }
      },
      {
        "loader": "sass-loader",
        "options": {
          "sourceMap": false,
          "precision": 8,
          "includePaths": []
        }
      }
    ]
  },
  {
    "include": [
      path.join(process.cwd(), "src/assets/stylesheets/styles.scss")
    ],
    "test": /\.scss$|\.sass$/,
    "loaders": screenStyleExtractor.extract({
      "use": [
        {
          "loader": "css-loader",
          "options": {
            "sourceMap": false,
            "importLoaders": 1
          }
        },
        {
          "loader": "postcss-loader",
          "options": {
            "ident": "postcss",
            "plugins": postcssPlugins
          }
        },
        {
          "loader": "sass-loader",
          "options": {
            "sourceMap": false,
            "precision": 8,
            "includePaths": []
          }
        }
      ],
      "publicPath": ""
    })
  },
  {
    "include": [
      path.join(process.cwd(), "src/assets/stylesheets/mobile.scss")
    ],
    "test": /\.scss$|\.sass$/,
    "loaders": mobileStyleExtractor.extract({
      "use": [
        {
          "loader": "css-loader",
          "options": {
            "sourceMap": false,
            "importLoaders": 1
          }
        },
        {
          "loader": "postcss-loader",
          "options": {
            "ident": "postcss",
            "plugins": postcssPlugins
          }
        },
        {
          "loader": "sass-loader",
          "options": {
            "sourceMap": false,
            "precision": 8,
            "includePaths": []
          }
        }
      ],
      "publicPath": ""
    })
  },
  {
    "test": /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
    "enforce": 'pre',
    "use": [
      "@ngtools/webpack"
    ]
  },
  {
    "test": /\.ts$/,
    "enforce": 'pre',
    "loader": 'webpack-strip-block'

  },
]
},

0 个答案:

没有答案