webpack-contrib / i18n-webpack-plugin

[DEPRECATED] Embed localization into your bundle
MIT License
317 stars 74 forks source link

Can't get this to play well with babel es6 #10

Closed anthony-dandrea closed 8 years ago

anthony-dandrea commented 8 years ago

Having some trouble trying to get this i18n plugin working with the babel-loader. It seems the loader isn't running before the plugin perhaps. Not sure. Relevant files below.

My config file

var path        = require("path"),
    I18nPlugin  = require("i18n-webpack-plugin"),
    webpack     = require("webpack"),
    languages   = {
        "en": null,
        "es": require("./src/locale/es.po.json")
    };

module.exports = Object.keys(languages).map(function(language) {
    return {
        name: language,
        entry: {
            home: "./src/static/scripts/script.js",
            alt: "./src/static/scripts/alt.js"
        },
        output: {
            path: path.join(__dirname, "dist/static/scripts"),
            filename: language + ".[name].output.js"
        },
        modules: {
            loaders: [
                {
                    test: /\.js$/,
                    exclude: /node_modules/,
                    loader: ["babel-loader"]
                },
            ]
        },
        plugins: [
            new I18nPlugin(
                languages[language]
            ),
            new webpack.optimize.UglifyJsPlugin({minimize: true})
        ]
    };
});

Error received:

    ERROR in ./src/static/scripts/script.js
    Module parse failed: /Users/anthonydandrea/react/gulp-react-flask/src/static/scripts/script.js Line 1: Unexpected token
    You may need an appropriate loader to handle this file type.
    | import React from 'react';

Thank you

anthony-dandrea commented 8 years ago

Figured it out http://stackoverflow.com/questions/32833381/webpack-i18n-plugin-not-working-with-babel-es6