webpack-component使用babel loader

时间:2015-09-17 00:56:33

标签: webpack

如何使用babel加载程序使用组件插件加载webpack-components。

我的Webpack-config.json看起来像这样:

var ComponentPlugin = require("component-webpack-plugin");
module.exports = {
entry: "./entry.js",
output: {
    path: __dirname,
    filename: "[name].js"
},
 resolve: {
    extensions: [ '', '.js', '.css' ]
},
module: {
    loaders: [
        { test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
       { test: /\.css$/, loader: "style!css" }
    ]
},
plugins: [
    new ComponentPlugin({
        // This is equal to: xyz: "[file]"

        // Load xyz field with the xyz-loader
         scripts: "!babel-loader![file]"

    }, [
        // Lookup paths 
        "components"
    ])
]
};

但是当我在我的组件js文件中使用require(' react')时,它仍然会抛出我的解析错误。

0 个答案:

没有答案