shlomiassaf / ngc-webpack

Angular compiler-cli with webpack's loader chain.
MIT License
84 stars 15 forks source link

AOT build with angular i18n #30

Open sandrasie opened 7 years ago

sandrasie commented 7 years ago

We are currently trying to get our AOT build to work with i18n. The Angular i18n docs (https://angular.io/guide/i18n) say ngc needs some arguments to make AOT include translation files: ./node_modules/.bin/ngc --i18nFile=./locale/messages.es.xlf --locale=es --i18nFormat=xlf

We found that NgcWebpackPlugin has an option called cliOptions that gets transformed to a instance of NgcCliOptions. So we tried to configure NgcWebpackPlugin in our webpack config as follows:

   new ngcWebpack.NgcWebpackPlugin({
        disabled: !AOT,
        tsConfig: helpers.root('tsconfig.webpack.json'),
        resourceOverride: helpers.root('config/resource-override.js'),
        cliOptions: {
            i18nFormat: 'xtb',
            i18nFile: './i18n/messages.en.xtb',
            locale: 'en',
        }
      })

But nothing happens... no error but also no translations. Are we missing something? Is anything wrong with options object? We couldn't find any examples out there. Or is there anything else we need to do or include to get translations compiled into the AOT build?