How to integrate an Angular component in React remote using ModuleFederation - reactjs

I have the following structure:
-mfp/
- react-host/
- webpack.dev.js
- index.js
- bootstrp.js
- src/
- App.js
- angular-remote/
- webpack.config.js
- src/
- main.ts
- bootstrp.ts
- app/
- app.module.ts
my webpack.config.js in my angular-remote look the following
const webpack = require('webpack');
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
module.exports = {
output: {
uniqueName: "ang",
publicPath: "http://localhost:8082/"
},
optimization: {
runtimeChunk: false
},
plugins: [
new ModuleFederationPlugin({
library: { type: 'var', name: 'ang' },
name: "ang",
filename: "remoteEntry.js",
exposes: {
'./angApp': './src/app/app.component.ts',
},
shared: {
'#angular/core': { eager: true, singleton: true },
'#angular/common': { eager: true, singleton: true },
'#angular/router': { eager: true, singleton: true },
},
}),
],
};
My webpack.dev.js in my react-remote look the following
const { merge } = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
const packageJson = require('../package.json');
module.exports = = {
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['#babel/preset-react', '#babel/preset-env'],
plugins: ['#babel/plugin-transform-runtime'],
},
},
},
],
},
mode: 'development',
devServer: {
port: 8081,
historyApiFallback: {
index: 'index.html',
},
},
plugins: [
new ModuleFederationPlugin({
name: 'marketing',
filename: 'remoteEntry.js',
exposes: {
'./MarketingApp': './src/bootstrap',
},
shared: packageJson.dependencies,
}),
new HtmlWebpackPlugin({
template: './public/index.html',
}),
],
};
My app.module.ts is the following:
import { BrowserModule } from '#angular/platform-browser';
import { AppComponent } from './app.component';
#NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
// bootstrap: []
bootstrap: [AppComponent]
})
export class AppModule { }
Still I don't see my angular app in my react, I can import in my react-host App.js the following
import angApp from 'ang/angApp'
without any error,I even see at the network tab in the console the call's to the JS return successfully but nothing appears.

I found a wonderful git repo that implements exactly what I intended to do. if any one come across this issue, worth checking it out.

Related

SVGs and PNGs not loading

I am working on a micro frontend using Webpack.
And I have a problem where all local my SVGs and PNGs are not being loaded by Webpack5 react app. I keep getting 404 when doing that.
Can anyone point me out what I am doing wrong?
Here is the folder structuring
/public
/src
/components
navbar.tsx
/assets
Logo.svg
webpack.config.js
Here is my Webpack config. I am including the loader for assets, as indicated in the Webpack documentation
Webpack.config.js
const HtmlWebPackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const deps = require("./package.json").dependencies;
module.exports = {
output: {
publicPath: "http://localhost:3000/",
},
resolve: {
extensions: [".vue", ".tsx", ".ts", ".jsx", ".js", ".json"],
},
devServer: {
port: 3000,
historyApiFallback: true,
},
module: {
rules: [
{
test: /\.m?js/,
type: "javascript/auto",
resolve: {
fullySpecified: false,
},
},
{
test: /\.(css|s[ac]ss)$/i,
use: ["style-loader", "css-loader", "postcss-loader"],
},
{
test: /\.(ts|tsx|js|jsx)$/,
exclude: /node_modules/,
use: { loader: "babel-loader" },
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
],
},
plugins: [
new ModuleFederationPlugin({
name: "App1",
filename: "remoteEntry.js",
remotes: {},
exposes: {},
shared: {
...deps,
react: {
singleton: true,
requiredVersion: deps.react,
},
"react-dom": {
singleton: true,
requiredVersion: deps["react-dom"],
},
},
}),
new HtmlWebPackPlugin({
template: "./src/index.html",
}),
],
};
And here is one of the images imported in the Navbar.
Navbar.tsx
import React from "react";
export default function Navbar() {
return (
<img src="./assets/Logo.svg" alt="Logo" />
)
}
I'm not an expert in react but with the app rendered in App.js maybe your url img src should be something like src='./components/assets/ because it would start from the src folder ? (i know if it's an import it works as expected but here it's a src ..)
Feel free to delete i didn't have enough karma to comment

Webpack - TypeError: $ is not a function

i am new to webpack and i am creating a react application using webpack. I am getting this error while compiling TypeError: $ is not a function.
I am not using jquery but my node modules include some third party libraries.
I was only able to find one related article to this problem but it related to jquery.
Webpack - $ is not a function
Is there anything wrong with my webpack and babel config:
webpack.config.js
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const FaviconsWebpackPlugin = require("favicons-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = (env) => {
console.log("WEBPACK ENV: ", env);
const isDevMode = env !== "production";
let config = {
entry: ["./src/index.js"],
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].[contenthash].js"
},
resolve: {
extensions: [".js", ".jsx"]
},
plugins: [
new CleanWebpackPlugin(),
new FaviconsWebpackPlugin("./src/logo.png"),
new HtmlWebpackPlugin({
template: "./src/index.html",
minify: {
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true
}
}),
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css"
})
],
module: {
rules: [
{
test: /\.scss$/,
use: ["css-loader", "sass-loader"]
},
{
test: /\.jsx?$/,
exclude: /node_modules\/(?!(sdk1|sdk2)\/).*/,
use: ["babel-loader"]
},
{
test: /\.(ac3|gif|jpe?g|m4a|mp3|ogg|png|svg|otf)$/,
loader: "file-loader",
options: {
outputPath: "./assets"
}
}
]
},
optimization: {
minimize: true,
minimizer: [new OptimizeCssAssetsPlugin(), new TerserPlugin()],
splitChunks: {
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
chunks: "all"
}
}
}
}
};
// Mode
config.mode = isDevMode ? "development" : "production";
// Dev Tools
config.devtool = isDevMode ? "inline-source-map" : false;
// Plugins
if (!isDevMode) {
config.plugins.push(new BundleAnalyzerPlugin({ analyzerPort: 8181 }));
}
// Dev Server
if (isDevMode) {
config.devServer = {};
config.devServer.disableHostCheck = true;
}
return config;
};
babel.config.js
module.exports = {
plugins: [
"#babel/plugin-syntax-dynamic-import",
"#babel/plugin-transform-object-assign",
[
require.resolve("babel-plugin-module-resolver"),
{
root: ["./src/"],
alias: {
js: "./src/js",
scss: "./src/scss",
components: "./src/js/components",
containers: "./src/js/containers",
phaser_path: "./src/js/phaser",
services: "./src/js/services",
constants: "./src/js/constants"
}
}
]
],
presets: [
[
"#babel/preset-env",
{
useBuiltIns: "usage",
corejs: 3,
modules: false,
debug: true,
targets: {
browsers: [">0.25%", "ie >= 11"]
}
}
],
[
"#babel/preset-react",
{
development: true
}
]
]
};
I think it is related to the html-webpack-plugin but i don't know for sure. Any help is appreciated.
Thanks
I am currently using this as a workaround to polyfill for now as the useBuiltIns property is not working for me.
Installed the following packages: babel-polyfill, es6-promise, whatwg-fetch
npm i babel-polyfill
npm i --save-dev es6-promise whatwg-fetch
In webpack.config.js did these changes
Require es6-promise on top require("es6-promise").polyfill();
Add whatwg-fetch and babel-polyfill to the entry property in config like this
entry: ["whatwg-fetch", "babel-polyfill", "./src/index.js"]

Unable to import sass files in react

I'm using the following boilerplate : https://github.com/spravo/typescript-react-express
I designed a first component : Button
import * as React from 'react';
import './button.scss';
export interface IButton {
value: string;
onClick: () => void;
}
class Button extends React.Component<IButton, {}> {
public render () {
return (
<div className='Button'>
<button onClick={this.props.onClick} className='Button__btn'>
{this.props.value}
</button>
</div>
);
}
}
export default Button;
And in the button.scss I have this simple line :
.Button {
background-color: red;
}
But I get the following error :
(function (exports, require, module, __filename, __dirname) { .Button {
SyntaxError: Unexpected token .
This is my webpack config (quite the same as the one from the repo) except the config.common.js for the webpack migration :
'use strict';
const path = require('path');
const webpack = require("webpack");
const config = require('../config')(process.env.NODE_ENV);
const vendors = require('./vendor');
const NODE_ENV = process.env.NODE_ENV || 'development';
module.exports = function getConfig(dirname) {
return {
target: 'web',
context: path.resolve(dirname),
stats: {
chunks: false,
colors: true,
},
entry: {
vendor: vendors
},
resolve: {
extensions: [ '.ts', '.tsx', '.js', '.scss', '.css' ],
modules: [
path.resolve(__dirname, '..', 'src'),
path.resolve(__dirname, '..', 'node_modules'),
]
},
output: {
path: config.PUBLIC_FOLDER,
filename: '[name].[hash].js',
chunkFilename: '[name].[chunkhash].js',
publicPath: config.PUBLIC_PATH
},
module: {
rules: []
},
optimization:{
splitChunks:{
name: 'vendor'
}
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'vendor'
// }),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(NODE_ENV)
},
__CLIENT__: true,
__SERVER__: false,
__DEV__: NODE_ENV === 'development',
__TEST__: false
})
]
};
};
The Css loaders :
'use strict';
const isDevelopment = (process.env.NODE_ENV || 'development') === 'development';
const autoprefixer = require('autoprefixer');
module.exports = {
scssLoader: [
{
loader: 'css-loader',
options: {
minimize: !isDevelopment,
sourceMap: isDevelopment
}
},
{
loader: 'postcss-loader',
options: {
sourceMap: isDevelopment,
plugins: [
autoprefixer({
browsers:['ie >= 8', 'last 4 version']
})
]
}
},
{
loader: 'sass-loader',
options: {
sourceMap: isDevelopment
}
}
]
};
It seems that the only scss that works is in the styles/index.scss but I don't get why it doesn't take other scss files.
My tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"baseUrl" : "./src",
"target": "es5",
"jsx": "react",
"alwaysStrict": true,
"sourceMap": true,
"outDir": "dist",
"lib": [
"dom",
"es2015",
"es5",
"es6"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"typings"
],
"exclude": [
"node_modules"
]
}
It is really weird that your webpack config "module.rules" is an empty array!
That is where your loader settings should be added.
If I were you, I would have copied the content of css-loaders config file and pasted in your webpack.config.js file. Make sure you store it in a normal variable/object instead of module.exports.
This is how my webpack config looks like:
const styleLoader = {
test: /\.(scss)$/,
include: path.resolve(__dirname, 'src'),
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true,
minimize: true
}
}, {
loader: 'postcss-loader',
options: {
sourceMap: true,
config: {
path: path.join(__dirname, 'postcss.config.js')
}
}
}, {
loader: 'sass-loader',
options: { sourceMap: true }
}
]
})
};
And then my webpack config looks like below. Pay attention to the modules.rules section:
module.exports = {
entry: {
app: ['babel-polyfill', 'whatwg-fetch', srcPath('index.js')],
silentrenew: [srcPath('silentrenew.js')]
},
output: {
path: path.resolve(__dirname, 'build'),
publicPath: '/',
filename: '[name].js'
},
devtool: 'source-map',
plugins: [
htmlPlugin('index.html', 'app'),
new ExtractTextPlugin('bundle.css'),
],
module: {
rules: [
babelLoader,
fontLoader,
svgLoader,
styleLoader
]
}
};

Asp.Net Core SpaTemplate never can get Angular Material to work

I have been trying for weeks to get Angular Material into the SpaTemplate from Microsoft. Can someone please help me understand why I simply cannot follow the startup guide for Angular Material and have it work? Can someone please help me get a project to the point that I can start to work with Angular Material from the SpaTemplate.
I have turned off server-side pre-rendering, because I am aware that causes problems. But aside from that I have tried installing Angular Material, I see some errors in the cmd. I import and add MaterialModule, then I see more errors talking about 'ng-template' is not a known element. I have removed the UniversalModule from my imports array and that causes more problems.
Repo here if someone could please help. Repo
Also am I the only developer who is coming from Angular 1.x and honestly not interested at all? Angular 1 was easy to develop in, the setup wasn't that hard, and adding outside code was as easy as copy and paste. Angular 2 feels like they made this really great framework and then no one knows how to use it when it comes to hosting it on a server.
I started with the new template that was just released with core 2. I have everything working except the table...not sure why yet on that one.
Tried priming and other, without success. Closest on Material..just no tables yet and not sure I understand the datasource.
Hope this helps...still a newbie on this stuff.
Don't forget to manually rebuild webpack after you make changes.
webpack --config webpack.config.vendor.js
webpack.vendor
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const merge = require('webpack-merge');
const treeShakableModules = [
'#angular/animations',
'#angular/common',
'#angular/compiler',
'#angular/core',
'#angular/forms',
'#angular/http',
'#angular/platform-browser',
'#angular/platform-browser-dynamic',
'#angular/router',
'#angular/material',
'#angular/cdk',
'zone.js'
];
const nonTreeShakableModules = [
'bootstrap',
'hammerjs/hammer',
"#angular/material/prebuilt-themes/indigo-pink.css",
'bootstrap/dist/css/bootstrap.css',
'font-awesome/css/font-awesome.css',
'es6-promise',
'es6-shim',
'event-source-polyfill',
'jquery',
];
const allModules = treeShakableModules.concat(nonTreeShakableModules);
module.exports = (env) => {
const extractCSS = new ExtractTextPlugin('vendor.css');
const isDevBuild = !(env && env.prod);
const sharedConfig = {
stats: { modules: false },
resolve: { extensions: [ '.js' ] },
module: {
rules: [
{ test: /\.(png|woff|woff2|eot|ttf|svg|gif|jpg)(\?|$)/, use: 'url-loader?limit=100000' }
]
},
output: {
publicPath: 'dist/',
filename: '[name].js',
library: '[name]_[hash]'
},
plugins: [
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new webpack.ContextReplacementPlugin(/\#angular\b.*\b(bundles|linker)/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/11580
new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)#angular/, path.join(__dirname, './ClientApp')), // Workaround for https://github.com/angular/angular/issues/14898
new webpack.IgnorePlugin(/^vertx$/) // Workaround for https://github.com/stefanpenner/es6-promise/issues/100
]
};
const clientBundleConfig = merge(sharedConfig, {
entry: {
// To keep development builds fast, include all vendor dependencies in the vendor bundle.
// But for production builds, leave the tree-shakable ones out so the AOT compiler can produce a smaller bundle.
vendor: isDevBuild ? allModules : nonTreeShakableModules
},
output: { path: path.join(__dirname, 'wwwroot', 'dist') },
module: {
rules: [
{ test: /\.css(\?|$)/, use: extractCSS.extract({ use: isDevBuild ? 'css-loader' : 'css-loader?minimize' }) }
]
},
plugins: [
extractCSS,
new webpack.DllPlugin({
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]'
})
].concat(isDevBuild ? [] : [
new webpack.optimize.UglifyJsPlugin()
])
});
const serverBundleConfig = merge(sharedConfig, {
target: 'node',
resolve: { mainFields: ['main'] },
entry: { vendor: allModules.concat(['aspnet-prerendering']) },
output: {
path: path.join(__dirname, 'ClientApp', 'dist'),
libraryTarget: 'commonjs2',
},
module: {
rules: [ { test: /\.css(\?|$)/, use: ['to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] } ]
},
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname, 'ClientApp', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]'
})
]
});
return [clientBundleConfig, serverBundleConfig];
}
I using the app.module.shared with the asp-rendering removed from index.
import { NgModule } from '#angular/core';
import { CommonModule } from '#angular/common';
import { FormsModule, ReactiveFormsModule} from '#angular/forms';
import { HttpClientModule } from '#angular/common/http';
import { RouterModule } from '#angular/router';
import { AppComponent } from './components/app/app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component';
import { HttpTestComponent } from './components/Httptest/httptest.component';
import { MaterialTesterComponent } from './components/Httptest/materialTester.component';
import { MaterialGridComponent } from './components/Httptest/materialgrid.component';
import { MaintService } from './Services/maint.service';
import {
MdButtonModule,
MdChipsModule,
MdProgressSpinnerModule,
MdCardModule,
MdDatepickerModule,
MdInputModule,
MdAutocompleteModule,
MdNativeDateModule,
MdCheckboxModule,
MdRadioModule,
MdSelectModule,
MdSliderModule,
MdSlideToggleModule,
MdMenuModule,
MdListModule,
MdGridListModule,
MdTabsModule,
MdProgressBarModule,
MdTableModule,
MdCoreModule,
MdExpansionModule,
} from '#angular/material';
import { CdkTableModule } from '#angular/cdk';
#NgModule({
declarations: [
AppComponent,
NavMenuComponent,
CounterComponent,
FetchDataComponent,
HomeComponent,
HttpTestComponent,
MaterialTesterComponent,
MaterialGridComponent,
],
imports: [
CommonModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule,
CdkTableModule,
MdButtonModule,
MdChipsModule,
MdProgressSpinnerModule,
MdCardModule,
MdInputModule,
MdTabsModule,
MdExpansionModule,
MdDatepickerModule,
MdNativeDateModule,
MdCheckboxModule,
MdRadioModule,
MdListModule,
MdCoreModule,
MdProgressBarModule,
MdSelectModule,
MdSliderModule,
MdSlideToggleModule,
MdMenuModule,
MdGridListModule,
MdTableModule,
MdAutocompleteModule,
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: '**', redirectTo: 'home' }
])
],
providers: [
MaintService
]
})
export class AppModuleShared {
}

TypeError: Cannot read property 'contextTypes' of undefined (karma+jasmine+reactRedux+webpack)

I am trying to execute jasmine test case of react+redux on webpack+karma background.
But getting below error
Below I have added webpack,karma config and react+redux component file.
1 ] karma.config.js
var webpackConfig = require('./webpack.config.js');
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'app/assets/test/**/*Spec.js',
'app/assets/test/**/*Spec.jsx'
],
preprocessors: {
'app/assets/test/**/*Spec.js': ['webpack'],
'app/assets/test/**/*Spec.jsx': ['webpack']
},
webpack: webpackConfig,
reporters: ['kjhtml'],
port: 9876,
colors: true,
config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: true,
concurrency: Infinity
})
}
2 ] react home.jsx component
import CarouselContainer from 'containers/carouselContainer'
import CurrentTracks from 'containers/currentTracks'
export default class Home extends React.Component {
render() {
return (
<div>
<CarouselContainer />
<CurrentTracks />
</div>
)
}
}
3 ] home.Spec.jsx -
import React from 'react';
import { shallow } from 'enzyme';
import ReactTestUtils from 'react-addons-test-utils'
import {Home} from 'pages/home'
describe("User suite", function() {
const wrapper = shallow(<Home/>);
expect(wrapper.length).toEqual(1);
});
4 ] Webpack.config.js -
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var merge = require('webpack-merge');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var BUILD = path.join(__dirname, 'build');
var APP = path.join(__dirname, 'app');
var JS = path.join(APP, 'assets', 'javascript');
var env = process.env.NODE_ENV;
console.log('Webpack env: ' + env)
var sassLoaders = [
'css-loader',
'postcss-loader',
'sass-loader?indentedSyntax=sass&includePaths[]=' + APP
];
var commonConfig = {
entry: [ path.join(JS, 'index.jsx') ],
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loaders: ['babel-loader'] },
{ test: /\.css/, loader: 'style-loader!css-loader?name=assets/css/[name]-[hash].[ext]' },
{ test: /\.png|jpg|gif$/, loader: 'file-loader?name=assets/images/[name]-[hash].[ext]' },
{ test: /\.xlsx$/, loader: 'file-loader?name=assets/file/[name].[ext]' },
{ test: /\.sass$/, loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!')) },
{ test: /\.(woff|woff2|svg|ttf|eot|ico)$/, loader: 'file-loader?name=assets/fonts/[name].[ext]' }
]
},
output: {
filename: 'assets/javascript/[name]-[hash].js',
path: BUILD,
publicPath: '/'
},
externals: {
'jsdom': 'window',
'cheerio': 'window',
'react/lib/ExecutionEnvironment': true,
'react/addons': true,
'react/lib/ReactContext': 'window'
},
plugins: [
new HtmlWebpackPlugin({
template: 'app/index.html',
inject: 'body',
filename: 'index.html',
favicon: path.join(APP, 'assets', 'images', 'favicon.ico')
}),
new ExtractTextPlugin('assets/stylesheet/[name]-[hash].min.css'),
new CopyWebpackPlugin([
{ from: path.join(APP,'assets/javascript/vendor'), to: 'assets/vendor' }
]),
new CopyWebpackPlugin([
{ from: path.join(APP,'assets/test'), to: 'assets/test' }
]),
new webpack.ProvidePlugin({
React: "react",
"_": "lodash"
})
],
postcss: [
autoprefixer({
browsers: ['last 2 versions']
})
],
resolve: {
root: path.join(APP, 'assets'),
alias: {
config: '../../../../configs',
images: 'images',
actions: 'javascript/actions',
containers: 'javascript/containers',
components: 'javascript/components',
common: 'components/common',
constants: 'javascript/constants',
javascript: 'javascript',
layout: 'components/layout',
mywagers: 'pages/myWagers',
pages: 'components/pages',
home: 'pages/home',
utility: 'javascript/utility',
wagers: 'pages/wagers',
sheets: 'wagers/betPad/sheets'
},
extensions: ['', '.js', '.jsx', '.sass'],
modulesDirectories: ['app', 'node_modules']
}
};
var devConfig = {
devtool: 'inline-source-map',
entry: ['webpack-hot-middleware/client?reload=true'],
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env || 'development')
})
],
module: {
postLoaders: [
{
test: /\.js$/,
exclude: [/node_modules/,/vendor/],
loader: "jshint-loader"
}
]
}
};
var prodConfig = {
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env || 'production')
})
]
};
var config;
switch (env) {
case 'development':
config = merge(devConfig, commonConfig);
break;
default:
config = merge(prodConfig, commonConfig);
break;
}
module.exports = config;
It looks like Home is a default export, so in your spec on line 4, you should be importing as a default.
So the line should look like
import Home from 'pages/home';
instead of
import {Home} from 'pages/home';

Resources