webpack i18n插件不会生成任何内容

时间:2016-01-26 11:46:50

标签: javascript webpack

我正在尝试在我的webpack配置中使用i18n webpack插件,我的配置文件是:

var languages = {
  en: require("./i18n/en.json"),
  tr: require("./i18n/tr.json")
};

module.exports = Object.keys(languages).map(function(language) {
  return {
    name: language,
    entry: {
      lib: ["react", "react-dom"],
      app: "./ui-v2/app/app.js",
      app2: "./ui-v2/app/app2.js"
  },
  output: {
    path: path.join(__dirname, "target/ui/v2"),
    filename: "app/[name]." + language + ".[chunkhash].min.js"
  },
  module: {
    loaders: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: "babel"
      },
      {
        test: /\.(png|jpg|svg)/,
        loader: "file-loader?name=img/[name].[hash].[ext]"
      },
      {
        test: /\.scss$/,
        loader: ExtractTextPlugin.extract("style-loader", "css-  loader!autoprefixer-loader!sass-loader", {
        publicPath: __dirname
        // allChunks: true
      })
      },
      {
        test: /\.(woff|woff2|ttf|eot)$/,
        loader: "file-loader?name=fonts/[name].[hash].[ext]"
      }
    ]
  },
  plugins: [
    new I18nPlugin(languages[language], "__i18n", true),
    new webpack.optimize.CommonsChunkPlugin({
      name: "common",
      fileName: "app/common.[chunkhash].js",
      chunks: ["app", "app2"]
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: "lib",
      fileName: "app/lib.[chunkhash].js"
    }),
    new webpack.ProvidePlugin({
      React: "react",
      ReactDOM: "react-dom",
      $: "jquery",
      _: "lodash"
    }),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        warnings: false
      },
      mangle: {
        except: ["exports", "import", "$", "_", "require", "React", "ReactDOM"]
        }
      }),
      new ExtractTextPlugin("styles/[name].[contenthash].css"),
      new Manifest({
        fileName: "manifest." + language + ".json"
      })
    ]
  };
});

我从gulp任务运行webpack:

webpack(webpackConfig, (err, stats) => {
        if (err) {
          throw new gUtil.PluginError("webpack", err);
        }
        gUtil.log("[webpack]", stats.toString());
      });

我在任务结束时得到的是:

[13:43:48] Using gulpfile 
[13:43:48] Starting 'default'...
[13:43:48] Starting 'webpack'...
[13:43:48] Webpack started on Dist Mode...
[13:43:48] Finished 'webpack' after 42 ms
[13:43:48] Finished 'default' after 47 ms
[13:43:48] [webpack] Hash: 616af9ca8c2785d009e4
Version: webpack 1.12.10
Time: 13ms

目标文件夹完全为空。我按照documentation中的步骤操作,我不知道我做错了什么。

有什么想法吗?谢谢。

0 个答案:

没有答案
相关问题