MaximBalaganskiy / AureliaDotnetTemplate

Aurelia .Net Template
43 stars 14 forks source link

Adding i18n #11

Closed gcastre closed 5 years ago

gcastre commented 5 years ago

Hello,

I tried to add aurelia-i18n and I have a problem with webpack, I followed the documentation, and everything works fine except when I edit a file that trigger the webpack watch.

When I launch the first time, my translation.json are copied to a locales folder inside the dist but when the watch triggers it remove the translation.json without re-copying them.

Here is how I configured the locales copy:

plugins: [
    new CleanWebpackPlugin(),
    new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
    new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "window.jQuery": "jquery" }),
    new HtmlWebpackPlugin({ template: 'index.ejs', filename: "../../wwwroot/index.html", inject: false, metadata: {}, alwaysWriteToDisk: true }),
    new AureliaPlugin({ aureliaApp: "boot" }),
    new GlobDependenciesPlugin({ "boot": ["ClientApp/**/*.{ts,html}"] }),
    new ModuleDependenciesPlugin({}),
    new MiniCssExtractPlugin({
        filename: "[name].[hash].css",
        chunkFilename: "[name].[chunkhash].css"
    }),
    new CopyWebpackPlugin([
        { from: 'ClientApp/app/locales/', to: 'locales/' }
    ]),
],

I don't know why the CopyWebpackPlugin don't trigger when the watch is called. Do you have any idea why ?

Thanks.

gcastre commented 5 years ago

Ok after a bit of digging you have to add

    new CleanWebpackPlugin({
        cleanAfterEveryBuildPatterns: ['!**/locales/**/translation.json'],
    }),

Sorry i've never played with webpack, should have done better research before posting !

MaximBalaganskiy commented 5 years ago

You might want to have a look https://github.com/webpack-contrib/copy-webpack-plugin/issues/252

On Wed, Jun 19, 2019, 12:59 AM Grégoire Castre notifications@github.com wrote:

Ok after a bit of digging you have to add

new CleanWebpackPlugin({ cleanAfterEveryBuildPatterns: ['!/locales//translation.json'], }),

Sorry i've never played with webpack, should have done better research before posting !

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MaximBalaganskiy/AureliaDotnetTemplate/issues/11?email_source=notifications&email_token=AA4KNPCFFJAS4YG5NIDS7VTP3DZ5XA5CNFSM4HY74IZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX65PWY#issuecomment-503175131, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4KNPH2FQFHT3UUDGWTHTDP3DZ5XANCNFSM4HY74IZQ .