/ / webpack com react.js aspnet - 'global' e 'exports' indefinido - javascript, webpack, reactjs.net

webpack com react.js aspnet - 'global' e 'exports' indefinido - javascript, webpack, reactjs.net

Eu estou tentando obter um aplicativo reagir trabalhando com o aspnet e estou usando o webpack.

Esta é a minha configuração do webpack

var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var pkg = require("./package.json");

// bundle dependencies in separate vendor bundle
var vendorPackages = Object.keys(pkg.dependencies).filter(function (el) {
return el.indexOf("font") === -1; // exclude font packages from vendor bundle
});

/*
* Default webpack configuration for development
*/
var config = {
devtool: "eval-source-map",
cache: true,
entry: {
main: path.join(__dirname, "app", "App.js"),
vendor: vendorPackages
},
output: {
path: path.join(__dirname, "js"),
filename: "[name].js",
sourceMapFilename: "[file].map"
},

resolve: {
modulesDirectories: ["node_modules"], alias: {}, extensions: ["", ".jsx", ".js"]
},
plugins: [
new webpack.OldWatchingPlugin(),  //needed to make watch work. see http://stackoverflow.com/a/29292578/1434764
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.js")
],
resolveLoader: {
"fallback": path.join(__dirname, "node_modules")
},
module: {
loaders: [{
test: /.js$/,
exclude: /node_modules/,
loader: "babel",
query: {
presets: ["es2015","react"]
}
}, {
test: /.css$/,
loader: "style!css!"
}]
}
}

/*
* If bundling for production, optimize output
*/
if (process.env.NODE_ENV === "production") {
config.devtool = false;

config.plugins = [
new webpack.optimize.OccurenceOrderPlugin(),

new webpack.optimize.UglifyJsPlugin({
comments: false,
compress: { warnings: false}
}),
new webpack.DefinePlugin({
"process.env": {NODE_ENV: JSON.stringify("production")}
})
];
};

module.exports = config;

Estou recebendo esses 2 erros no console quando tento acessar a página.

SCRIPT5009: "global" é indefinido vendor.js (42739,2)

SCRIPT5009: "exportações" é indefinido mobilelobbyapp.js (1,1)

Eu não consigo descobrir como consertar isso. Eu notei em um exemplo de trabalho que o arquivo js exportado do webpack tem

webpackJsonp([0],{

no início do arquivo onde o meu tem

exports.ids = [0];
exports.modules = {

Respostas:

0 para resposta № 1

Eu encontrei este post 'global' indefinido depois de executar o webpack e eu consegui consertar o SCRIPT5009: "global" é indefinido vendor.js adicionando

novo webpack.DefinePlugin ({global: {}}), para

plugins: [
new webpack.OldWatchingPlugin(),  //needed to make watch work. see     https://stackoverflow.com/a/29292578/1434764
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.js"),
new webpack.DefinePlugin({ global: {} }),
],

e então eu consertei SCRIPT5009: "exports" é indefinido removendo

target: "node",

do meu webpack.config