WebPack 2: Migrate preLoaders and postLoaders
Asked Answered
P

1

24

I've installed [email protected]. Before, I was using [email protected]. On my configuration file I was using preLoaders and postLoaders:

preLoaders: [
    {
      test: /\.ts$/,
      loader: 'string-replace-loader',
      query: {
        search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)',
        replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)',
        flags: 'g'
      },
      include: [helpers.root('src')]
    },

  ],
  loaders: [...],
  postLoaders: [
    {
      test: /\.js$/,
      loader: 'string-replace-loader',
      query: {
        search: 'var sourceMappingUrl = extractSourceMappingUrl\\(cssText\\);',
        replace: 'var sourceMappingUrl = "";',
        flags: 'g'
      }
    }
  ]

I'm not able to figure out once I've took a look on internet how to migrate this preLoaders and postLoaders.

Should I put them inside loaders? Only that?

Pseudonym answered 17/11, 2016 at 11:39 Comment(0)
A
37

From v2.1-beta.23 the loaders section is renamed to rules and pre/postLoaders is now defined under each rule with the enforce property.

I've answered in more detail in this thread

More info can also be found in the release notes on github

The release notes also mentions a migration example in the angular cli repo

Another tip is to look at the json schema that validates the config for hints.

Aggressive answered 17/11, 2016 at 12:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.