Code Monkey home page Code Monkey logo

react-toolbox-example's Introduction

npm version Build Status NPM Status Donate OpenCollective OpenCollective

React Toolbox is a set of React components that implement Google's Material Design specification. It's powered by CSS Modules and harmoniously integrates with your webpack workflow, although you can use any other module bundler. You can take a tour through our documentation website and try the components live!

Note: ⚠️ This source code refers to the future version. To check the source for 1.x go to master branch. There is a migration guide so you can start working with 2.0-beta.x now!

Installation

React Toolbox can be installed as an npm package:

$ npm install --save react-toolbox

Prerequisites

React Toolbox uses CSS Modules by default to import stylesheets written using PostCSS & postcss-preset-env features. In case you want to import the components already bundled with CSS, your module bundler should be able to require these PostCSS modules.

Although we recommend webpack, you are free to use whatever module bundler you want as long as it can compile and require PostCSS files located in your node_modules. If you are experiencing require errors, make sure your configuration satisfies this requirement.

Of course this is a set of React components so you should be familiar with React. If want to customize your components via themes, you may want to take a look to react-css-themr which is used by React Toolbox to make components easily themeable.

Usage in Create React App Projects

Create React App does not allow to change the default configuration, so you need an additional build step to configure react-toolbox in its project.

Follow these instructions to add react-toolbox to a project created with Create React App.

Usage in Webpack Projects (Not Create React App)

npm install postcss-loader --save-dev
npm install postcss postcss-preset-env postcss-calc --save

Configure webpack 1.x loader for .css files to use postcss:

      {
        test: /\.css$/,
        loaders: [
          'style-loader',
          'css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss?sourceMap&sourceComments',
        ],
      },

Declare plugins to be used by postcss (as part of webpack's config object):

  // webpack.config.js
  postcss: () => {
    return [
      /* eslint-disable global-require */
      require('postcss-preset-env')({
        stage: 0, // required to get all features that were from cssnext without enabling them one by one
        features: {
          'custom-properties': {
            preserve: false, // required to output values instead of variables
          },
          'color-mod-function': true, // required to use color-mod()
        }
      }),
      require('postcss-calc'), // required as postcss-preset-env doesn't have a reduce calc() funtion that cssnext did
      /* eslint-enable global-require */
    ];
  },

Configure webpack 2.x or 3.x loader for .css files to use postcss:

  // webpack.config.js
  {
    test: /\.css$/,
    use: [
      "style-loader",
      {
        loader: "css-loader",
        options: {
          modules: true, // default is false
          sourceMap: true,
          importLoaders: 1,
          localIdentName: "[name]--[local]--[hash:base64:8]"
        }
      },
      "postcss-loader"
    ]
  }

Basic usage

In this minimal example, we import a Button with styles already bundled:

import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from 'react-toolbox/lib/button';

ReactDOM.render(
  <Button label="Hello World!" />,
  document.getElementById('app')
);

Note: if you use it with Create React App, you need to make this additional change:

- import {Button} from 'react-toolbox/lib/button';
+ import Button from 'react-toolbox/lib/button/Button';

Take into account that any required style will be included in the final CSS so your final CSS would include Button styles in this case. It's more efficient to import components this way (from 'react-toolbox/lib/button') (or with raw imports) because if you require from the project root (i.e. from 'react-toolbox'), every stylesheet of React Toolbox will be included, even if you don't use it.

Importing components

First let's take a look on how the components are structured in the project. The components folder contains a folder for each component or set of related components. For example, the app_bar:

 |- /app_bar
 |---- AppBar.js
 |---- config.css
 |---- index.js
 |---- readme.md
 |---- theme.css

As you can see in the previous block, each folder includes: a Javascript file for each component/subcomponent; a README with documentation, an index Javascript file that imports and injects styles and dependencies for you, a default theme PostCSS/preset-env stylesheet and a config.css with configuration variables (CSS Custom Properties). Depending on whether you want the styles to be directly bundled or not, you can import components in two different ways.

Bundled component

If you import from the index file, the imported component comes with all dependencies and themes already required and injected for you. This means that the CSS for each dependency will be bundled in your final CSS automatically and the component markup includes the classnames to be styled. For example:

import { AppBar } from 'react-toolbox/lib/app_bar';

Raw component

If you import from the component definition, the imported component is bundled with its dependencies, but it does not include any styles. This means no CSS will be bundled, and the component markup will not include any classname. It's your responsibility to provide a theme to the component to be properly styled. You can do so via properties or context. For example:

import { AppBar } from 'react-toolbox/lib/app_bar/AppBar.js';

Customizing components

Every component accepts a theme property intended to provide a CSS Module import object that will be used by the component to assign local classnames to its DOM nodes. Therefore, each one implements a documented classname API. So if you want to customize a component, you just need to provide a theme object with the appropriate classname mapping.

If the component already has a theme injected, the properties you pass will be merged with the injected theme. In this way, you can add classnames to the nodes of a specific component and use them to add or to override styles. For example, if you want to customize the AppBar to be purple:

import React from 'react';
import { AppBar } from 'react-toolbox/lib/app_bar';
import theme from './PurpleAppBar.css';

const PurpleAppBar = (props) => (
  <AppBar {...props} theme={theme} />
);

export default PurpleAppBar;
.appBar {
  background-color: #800080;
}

In this case we are adding styles to a specific instance of an AppBar component that already has its default styles injected. It works because the component background by default has the same priority as the one we added. There will be cases where the original rule is more restrictive. For those cases you would need to boost priority using the same restrictions as in the original stylesheet. Feel free to take a look into the default theme.css files or just check the selectors you want to override in DevTools.

If the component has no styles injected, you should provide a theme object implementing the full API. You are free to require the CSS Module you want but take into account that every classname is there for a reason. You can either provide a theme via prop or via context as described in the next section.

Customizing all instances of a component type

Install react-css-themr with npm install react-css-themr --save

Create a CSS Module theme style file for each component type, for example for Button:

# /css/button.css

.button {
  text-transform: uppercase;
}

Create a theme file that imports each component's custom theme style under the special theme key listed in that widgets's documentation, i.e.:

# theme.js

import RTButton from './css/button.css';
import RTDatePicker from './css/datepicker.css';

export default {
  RTButton, RTDatePicker,
};

Wrap your component tree with ThemeProvider at the desired level in your component hierarchy. You can maintain different themes, each importing differently styled css files (i.e. import RTButton from './css/adminAreaButton.css') and can provide each one at different points in the tree.

import React from 'react';
import { ThemeProvider } from 'react-css-themr';
import theme from './theme';

class App extends React.Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <div>
          ...
        </div>
      </ThemeProvider>
    );
  }
}
export default App;

Theming (configuration variables)

You can apply theming in multiple ways. First of all, you have to understand that React Toolbox stylesheets are written using PostCSS with postcss-preset-env features and use CSS Custom Properties from the config files we saw earlier. In addition, there are some global CSS Properties imported by each component: colors and variables. You can override both the global and component-specific variables to get the results you want using one of the methods below.

Settings configuration variables in JavaScript

You can override both the global and component-specific CSS Custom Properties at build-time by supplying an object with these variable names and your desired values to the PostCSS custom-properties plugin. i.e. if using postcss-preset-env in webpack:

// This can also be stored in a separate file:
const reactToolboxVariables = { 
  'color-text': '#444548',
  /* Note that you can use global colors and variables */
  'color-primary': 'var(--palette-blue-500)',
  'button-height': '30px',
};

// webpack's config object: (webpack.config.js)
const config = {
...
    postcss: () => {
    return [
      /* eslint-disable global-require */
      require('postcss-preset-env')({
        stage: 0, // required to get all features that were from cssnext without enabling them one by one
        features: {
          'custom-properties': {
            preserve: false, // required to output values instead of variables
            importFrom: reactToolboxVariables, // see postcss-preset-env for config options
          },
          'color-mod-function': true, // required to use color-mod()
        }
      }),
      require('postcss-calc'), // required as postcss-preset-env doesn't have a reduce calc() funtion that cssnext did
      /* optional - see next section */
      require('postcss-modules-values'),
      /* eslint-enable global-require */
    ];
  },
}

Settings configuration variables using CSS Module Values

Instead of using a JavaScript object for variables, you can use CSS Module Values (npm install postcss-modules-values --save) and the modules-values-extract utility to declare these variables in component-specific theme .css files, where you would typically store additional style overrides.

CSS Module Values also offer the advantage that importing a css file with @value declarations makes these values properties of the imported style object, i.e.:

# variables.css

@value buttonPrimaryBackgroundColor: #9c3990;
import styleVariables from './css/variables.css';

styleVariables.buttonPrimaryBackgroundColor

In this demo project, modules-values-extract utility is used to extract all @values with dashes in their name from all css files in the /css folder and to feed them to customProperties in webpack. In the demo project, variables that are not specific to a particular component are in variables.css and button-specific variables are in button.css. Note that button.css also imports certain values from variables.css just to demonstrate this capability (the import can also be used in a @value declaration) and it uses CSS overrides instead of color variables that exist in the React-Toolbox Button component to show an alternative method if the variables are not sufficient.

IMPORTANT: Changes to the module values do not take effect immediately with Webpack Hot-Module-Reload - webpack / webpack-dev-server must be restarted!

Roboto Font and Material Design Icons

React Toolbox assumes that you are importing Roboto Font and Material Design Icons.

In order to import the fonts for you, we'd need to include them in the CSS which is considered a bad practice. If you are not including them in your app, go to the linked sites and follow the instructions.

Server Side Rendering

The only requirement for SSR is to be able to require ES6 and CSS Modules in the backend. To make it possible you can check projects like CSS Modules register hook or Webpack Isomorphic tools. Also, make sure you can import from node_modules.

Examples

For now we have a repository example demonstrating configuration and some basic customization. For now it's not using SSR rendering but it shouldn't be difficult to implement an example so it will come soon. Feel free to PR your example project or to add some use cases to the repository:

Another 2.x demo project is https://github.com/alexhisen/mobx-forms-demo

TypeScript

TypeScript external module definition files are included, and should not require any manual steps to utilize. They will be picked up by the TypeScript compiler when importing from the npm package.

Note that to comply with the official recommendation for npm typings, a triple-slash reference to react.d.ts is NOT included. You will need to reference react.d.ts somewhere in your project.

Authors and Contributors

The project is being initially developed and maintained by Javier Velasco and Javier Jiménez and the contribution scene is just getting warm. We want to create reference components so any contribution is very welcome.

To work in the project you'd need a node version supporting ES6 syntax. Although the project is built using Babel we use some ES6 features in the development server. Also, the package has been tested with node 4.2.1. Consider using nvm or n to handle different node versions!

To start the documentation site locally, you'll need to install the dependencies from both the main package and the docs subproject:

$ git clone https://github.com/react-toolbox/react-toolbox.git
$ cd react-toolbox/
$ npm install
$ cd docs/
$ npm install
$ npm start

Local documentation will then be available at http://localhost:8081/.

Extensions

We don't officially support components that are not covered by Google Material Design. If you want to implement some complementary component feel free to open a PR adding your a link in this section:

on github: react-toolbox-additions and on npm: react-toolbox-additions.

Form generation and validation using React-Toolbox form widgets - mobx-schema-form

Support

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

License

This project is licensed under the terms of the MIT license.

react-toolbox-example's People

Contributors

arlair avatar borillo avatar brauliodiez avatar javivelasco avatar kikobeats avatar nickpisacane avatar nogsmpls avatar olegstepura avatar rubenmoya avatar soyjavi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-toolbox-example's Issues

Webpack resolve modules question

When using the ExtractTextPlugin plugin to resolve all styles, won't this load stylesheets from other node module folders that are not part of react-toolbox and should thus be ignored?

extensions: ['', '.js', '.jsx', '.scss'], 
        modulesDirectories: [
            'node_modules',
            path.resolve(__dirname, './node_modules')
        ]

failed start script

Failed at the [email protected] start script 'cross-env NODE_ENV=development node_modules/.bin/webpack-dev-server --colors --config webpack.config.js'. in my windows 7

External postcss config

Hey, thank you for putting this resource together! I'm a little confused about the postcss config in a separate file. Where is webpack picking this up? This isn't an issue, but rather a clarification question.

Minor correction needed to make it work on Windows

webpack.config.js, module.exports.sassLoader.data injects @import with backslash-delimited path on Windows. Backslashes are interpreted as escape characters by sass loader, so the path gets corrupted and loader fails.
We need to either remove path.resolve here making sure that backslashes don't appear in the path, or replace backslashes with regular slashes after path.resolve (better alternative), or duplicate backslashes (perhaps even better one)

App Bar fixed property doesn't work

It seems that the fixed property of the App Bar doesn't work.

I have changed line 7 of header.jsx file to

<AppBar className={style.appbar} fixed flat>

Now the App Bar overlay the content.

ohne titel kopie

Best regards
Rico

how to solve this issue??

ERROR in .//react-toolbox/lib/button/theme.scss
Module parse failed: C:\Users\swapnil\Desktop\reactApp\node_modules\react-toolbox\lib\button\theme.scss Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '@' (1:0)
at Parser.pp$4.raise (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2221:15)
at Parser.pp$7.getTokenFromCode (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2756:10)
at Parser.pp$7.readToken (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2477:17)
at Parser.pp$7.nextToken (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2468:15)
at Parser.parse (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:515:10)
at Object.parse (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:3098:39)
at Parser.parse (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock. (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack\lib\NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
at nextLoader (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
@ ./
/react-toolbox/lib/button/index.js 26:13-36

ERROR in .//react-toolbox/lib/ripple/Ripple.js
Module not found: Error: Cannot resolve module 'immutability-helper' in C:\Users\swapnil\Desktop\reactApp\node_modules\react-toolbox\lib\ripple
@ ./
/react-toolbox/lib/ripple/Ripple.js 23:26-56

ERROR in .//react-toolbox/lib/ripple/theme.scss
Module parse failed: C:\Users\swapnil\Desktop\reactApp\node_modules\react-toolbox\lib\ripple\theme.scss Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '@' (1:0)
at Parser.pp$4.raise (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2221:15)
at Parser.pp$7.getTokenFromCode (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2756:10)
at Parser.pp$7.readToken (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2477:17)
at Parser.pp$7.nextToken (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:2468:15)
at Parser.parse (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:515:10)
at Object.parse (C:\Users\swapnil\Desktop\reactApp\node_modules\acorn\dist\acorn.js:3098:39)
at Parser.parse (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack\lib\Parser.js:902:15)
at DependenciesBlock. (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack\lib\NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack-core\lib\NormalModuleMixin.js:310:10)
at nextLoader (C:\Users\swapnil\Desktop\reactApp\node_modules\webpack-core\lib\NormalModuleMixin.js:275:25)
@ ./
/react-toolbox/lib/ripple/index.js 13:13-36
webpack: bundle is now VALID.

Problems with rendering Dialog component

Hi guys,

I'm having trouble with using a Dialog component. The way I try to implement it is:

import { Dialog } from 'react-toolbox/lib/dialog'
import theme from './pages.styles.module.scss'

state = { active: true };

closeConfirmation = () => {
   this.setState({ active: !this.state.active });
};

actions = [
    { label: "OK", onClick: this.closeConfirmation }
];
...
<Dialog actions={this.actions}
              active={this.state.active}
              onEscKeyDown={this.closeConfirmation}
              onOverlayClick={this.closeConfirmation}
              title='Links Sent'
              theme={theme}>
              <p>An email with download links has been sent to your inbox</p>
</Dialog>

I noticed that it is in fact, being present in the DOM, but it doesn't generate relevant classes for 'overlay' element and 'backdrop'. Rest of its content seems to be just fine, with all respective CSS classes present in the DOM. What might be the cause?

I should also mention that other components like <Button /> and <Input />, used in the same way, are rendered fine.

I am using version 1.3.4.

Install fails - won't compile -- Is this project dead?

ERROR in ./~/react-toolbox/components/index.js
Module build failed: SyntaxError: Unexpected token, expected { (24:7)

  22 | export { default as ProgressBar } from './progress_bar';
  23 | export * from './radio';
> 24 | export Ripple from './ripple';
     |        ^
  25 | export { default as Slider } from './slider';
  26 | export { default as Snackbar } from './snackbar';
  27 | export { default as Switch } from './switch';

 @ ./src/frontend/index.js 5:0-61
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch ./src/frontend/index.js
webpack: Failed to compile.

Add component unit tests using Jest

I have just started using React Toolbox, and find it quite hard to write some unit tests for components using React Toolbox Components. I believe it would be really helpful if such examples were available in this repository. What do you think?

TypeError: Cannot read property 'flat' of undefined

HI, looking forward to using what looks like a terrific set of components. I've been trying to get them installed in react-redux-universal-hot-example and am almost all the way there. I've got the webpack config set up and it's building all the way through with no errors, but when I view the site at local host, I'm getting this error:

TypeError: Cannot read property 'flat' of undefined
Button.render
D:\projects\rrum\node_modules\react-toolbox\lib\button\index.js:65:41

Any ideas on what might be causing this?

Remove stage-0 from required presets

This boilerplate depends on babel-preset-stage-0 -- which essentially means that projects that start off of this template will have to depend on ECMAScript features that have gained no acceptance.

No project should have a stage-0 dependency.

Hence pl;ease remove it from package.json.

Webpack babel experimental class support

Webpack throws following error on React Component:

Module build failed: SyntaxError: components/dialog/index.jsx: Unexpected token (20:15)
  18 |   }
  19 |
> 20 |   closeDialog = () => {
     |                ^
  21 |     this.refs.dialog.hide();
  22 |   };
  23 |

And this is the class, basically any class using babel experimental class support,

class DialogTest extends React.Component {
  showDialog = () => {
    this.refs.dialog.show();
  };

  closeDialog = () => {
    this.refs.dialog.hide();
  };

  actions = [
    { label: "Cancel", onClick: this.closeDialog },
    { label: "Save", onClick: this.closeDialog }
  ];

  render () {
    return (
      <div>
        <Button label='Show my dialog' onClick={this.showDialog} />
        <Dialog ref='dialog' title='My awesome dialog' type='small' actions={this.actions}>
          <p>Here you can add arbitrary content. Components like Pickers are using dialogs now.</p>
        </Dialog>
      </div>
    );
  }
}

return <DialogTest />;

I don't know how to enable babel exp. features with webpack 5.x.

Using in Isomorphic Application

Hi, I'm trying to use toolbpx in isomorphic application. But have some troubles...
Here is my webpack config:

import path from 'path';
import webpack from 'webpack';
import merge from 'lodash.merge';

import ExtractTextPlugin from 'extract-text-webpack-plugin';

const DEBUG = !process.argv.includes('release');
const VERBOSE = process.argv.includes('verbose');
const WATCH = global.WATCH === undefined ? false : global.WATCH;
const AUTOPREFIXER_BROWSERS = [
  'Android 2.3',
  'Android >= 4',
  'Chrome >= 35',
  'Firefox >= 31',
  'Explorer >= 9',
  'iOS >= 7',
  'Opera >= 12',
  'Safari >= 7.1',
];
const GLOBALS = {
  'process.env.NODE_ENV': DEBUG ? '"development"' : '"production"',
  __DEV__: DEBUG,
};
const JS_LOADER = {
  test: /\.jsx?$/,
  include: [
    path.resolve(__dirname, '../node_modules/react-routing/src'),
    path.resolve(__dirname, '../src'),
  ],
  loader: 'babel-loader',
};

//
// Common configuration chunk to be used for both
// client-side (app.js) and server-side (server.js) bundles
// -----------------------------------------------------------------------------

const config = {
  output: {
    publicPath: '/',
    sourcePrefix: '  ',
  },

  cache: DEBUG,
  debug: DEBUG,

  stats: {
    colors: true,
    reasons: DEBUG,
    hash: VERBOSE,
    version: VERBOSE,
    timings: true,
    chunks: VERBOSE,
    chunkModules: VERBOSE,
    cached: VERBOSE,
    cachedAssets: VERBOSE,
  },

  plugins: [
    new webpack.optimize.OccurenceOrderPlugin(),
  ],

  resolve: {
    extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx', '.scss'],
  },

  module: {
    loaders: [
      {
        test: /\.json$/,
        loader: 'json-loader',
      }, {
        test: /\.txt$/,
        loader: 'raw-loader',
      }, {
        test: /\.(png|jpg|jpeg|gif|svg|woff|woff2)$/,
        loader: 'url-loader?limit=10000',
      }, {
        test: /\.(eot|ttf|wav|mp3)$/,
        loader: 'file-loader',
      },
    ],
  },

  postcss: function plugins() {
    return [
      require('postcss-import')({
        onImport: files => files.forEach(this.addDependency),
      }),
      require('postcss-nested')(),
      require('postcss-cssnext')({ autoprefixer: AUTOPREFIXER_BROWSERS }),
    ];
  },
};

//
// Configuration for the client-side bundle (app.js)
// -----------------------------------------------------------------------------

const appConfig = merge({}, config, {
  entry: [
    ...(WATCH ? ['webpack-hot-middleware/client'] : []),
    './src/app.js',
  ],
  output: {
    path: path.join(__dirname, '../build/public'),
    filename: 'app.js',
  },

  // Choose a developer tool to enhance debugging
  // http://webpack.github.io/docs/configuration.html#devtool
  devtool: DEBUG ? 'cheap-module-eval-source-map' : false,
  plugins: [
    ...config.plugins,
    new ExtractTextPlugin('app.css'),
    new webpack.DefinePlugin(GLOBALS),
    ...(!DEBUG ? [
      new webpack.optimize.DedupePlugin(),
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          warnings: VERBOSE,
        },
      }),
      new webpack.optimize.AggressiveMergingPlugin(),
    ] : []),
    ...(WATCH ? [
      new webpack.HotModuleReplacementPlugin(),
      new webpack.NoErrorsPlugin(),
    ] : []),
  ],
  module: {
    loaders: [
      WATCH ? {
        ...JS_LOADER,
        query: {
          // Wraps all React components into arbitrary transforms
          // https://github.com/gaearon/babel-plugin-react-transform
          plugins: ['react-transform'],
          extra: {
            'react-transform': {
              transforms: [
                {
                  transform: 'react-transform-hmr',
                  imports: ['react'],
                  locals: ['module'],
                }, {
                  transform: 'react-transform-catch-errors',
                  imports: ['react', 'redbox-react'],
                },
              ],
            },
          },
        },
      } : JS_LOADER,
      ...config.module.loaders,
      {
        test: /(\.scss|\.css)$/,
        loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap'),
      },
    ],
  },
});

//
// Configuration for the server-side bundle (server.js)
// -----------------------------------------------------------------------------

const serverConfig = merge({}, config, {
  entry: './src/server.js',
  output: {
    path: './build',
    filename: 'server.js',
    libraryTarget: 'commonjs2',
  },
  target: 'node',
  externals: [
    function filter(context, request, cb) {
      const isExternal =
        request.match(/^[a-z][a-z\/\.\-0-9]*$/i) &&
        !request.match(/^react-routing/) &&
        !context.match(/[\\/]react-routing/);
      cb(null, Boolean(isExternal));
    },
  ],
  node: {
    console: false,
    global: false,
    process: false,
    Buffer: false,
    __filename: false,
    __dirname: false,
  },
  devtool: 'source-map',
  plugins: [
    ...config.plugins,
    new webpack.DefinePlugin(GLOBALS),
    new webpack.BannerPlugin('require("source-map-support").install();',
      { raw: true, entryOnly: false }),
  ],
  module: {
    loaders: [
      JS_LOADER,
      ...config.module.loaders,
      {
        test: /(\.scss|\.css)$/,
        loader: 'css/locals?module&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap',
      },
    ],
  },
});

export default [appConfig, serverConfig];

Actually building of bundle is done without errors, but when I try to run server.js - I get error:

Error: Cannot find module './style'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/some-path/node_modules/react-toolbox/lib/font_icon/index.js:15:14)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

In my server.js I do not using hot-middleware.

Tried to run it and it doesn't work

Build failed
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN Error: EPERM: operation not permitted, scandir 'C:\Users\gonzarey\Desktop\react-toolbox-example\node_modules\getpass\node_modules'
npm WARN { Error: EPERM: operation not permitted, scandir 'C:\Users\gonzarey\Desktop\react-toolbox-example\node_modules\getpass\node_modules'
npm WARN errno: -4048,
npm WARN code: 'EPERM',
npm WARN syscall: 'scandir',
npm WARN path: 'C:\Users\gonzarey\Desktop\react-toolbox-example\node_modules\getpass\node_modules' }
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "i"
npm ERR! node v7.5.0
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: node scripts/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node scripts/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\gonzarey\Desktop\react-toolbox-example\npm-debug.log

Red box of death.

Hello,
Im wondering if there is another way to show errors with this config (i dont want the red screen of death to show them, im fine with console)

Thanks

This is my webpack config.

const path = require('path');
const webpack = require('webpack');

const settings = {
  entry: {
    bundle: [
      "react-hot-loader/patch",
      "./src/frontend/index.js"
    ]
  },
  output: {
    filename: "[name].js",
    publicPath: "/",
    path: path.join(path.join(__dirname, 'dist'), 'js'),
    libraryTarget: "amd",
  },
  resolve: {
    //extensions: [".js", ".json", ".css"]
    extensions: ['.scss', '.css', '.js', '.json','.webpack.js', '.web.js', '.js', '.jsx']

  },
  //devtool: 'inline-source-map',
  devtool: 'source-map',
  module: {
    rules: [
      {
        test: /\.js?$/,
        loader: 'babel-loader',
        options: {
          presets: [
            ["es2015", { modules: false }],
            "stage-2",
            "react"
          ],
          plugins: [
            "transform-node-env-inline"
          ],
          env: {
            development: {
              plugins: ["react-hot-loader/babel"]
            }
          }
        }
      },
      {
        test: /\.css$/,
        use: [
          "style-loader",
          {
            loader: "css-loader",
            options: {
              modules: true,
              sourceMap: true,
              importLoaders: 1,
              localIdentName: "[name]--[local]--[hash:base64:8]"
            }
          },
          "postcss-loader" // has separate config, see postcss.config.js nearby
        ]
      },
    ]
  },
  externals: [
      function(context, request, callback) {
          if (/^dojo/.test(request) ||
              /^dojox/.test(request) ||
              /^dijit/.test(request) ||
              /^esri/.test(request)
          ) {
              return callback(null, "amd " + request);
          }
          callback();
      }
  ],
  devServer: {
  //  contentBase: path.resolve("src/www"),
  //  publicPath: "http://localhost:8080/", // full URL is necessary for Hot Module Replacement if additional path will be added.
  /*  quiet: false,
    hot: true,
    port: 443,
    host: "127.0.0.1",

    historyApiFallback: true,
    inline: true
    */

    inline: true,
    port: 443,
    host: "127.0.0.1",
    historyApiFallback: true

  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NamedModulesPlugin(),
    new webpack.LoaderOptionsPlugin({
      debug: true
    }),
  ],
};

module.exports = settings;

Redundant style duplication

In webpack.config.js we have something like this:

sassLoader: {
    data: '@import "theme/_config.scss";',
    includePaths: [path.resolve(__dirname, './src/app')]
  },

The data directive here appends any styles in _config.scss in EVERY css file it processes. Additionally, if _config.scss @imports any other styles, they are also appended. This is how css-loader works -- and there is no way around it.

Please have a look at this issue:
webpack-contrib/css-loader#17

Is there a solution for this?

Cannot find react-style-proptype modules

When I run npm install, then npm start, this happens.

ERROR in ./~/react-toolbox/lib/checkbox/Checkbox.js
Module not found: Error: Can't resolve 'react-style-proptype' in '/Users/waleo/Code/ya-pack/node_modules/react-toolbox/lib/checkbox'
 @ ./~/react-toolbox/lib/checkbox/Checkbox.js 38:26-57
 @ ./~/react-toolbox/lib/checkbox/index.js
 @ ./~/react-toolbox/lib/index.js
 @ ./src/frontend/index.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch ./src/frontend/index.js

ERROR in ./~/react-toolbox/lib/checkbox/Check.js
Module not found: Error: Can't resolve 'react-style-proptype' in '/Users/waleo/Code/ya-pack/node_modules/react-toolbox/lib/checkbox'
 @ ./~/react-toolbox/lib/checkbox/Check.js 15:26-57
 @ ./~/react-toolbox/lib/checkbox/index.js
 @ ./~/react-toolbox/lib/index.js
 @ ./src/frontend/index.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch ./src/frontend/index.js

ERROR in ./~/react-toolbox/lib/slider/Slider.js
Module not found: Error: Can't resolve 'react-style-proptype' in '/Users/waleo/Code/ya-pack/node_modules/react-toolbox/lib/slider'
 @ ./~/react-toolbox/lib/slider/Slider.js 32:26-57
 @ ./~/react-toolbox/lib/slider/index.js
 @ ./~/react-toolbox/lib/index.js
 @ ./src/frontend/index.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch ./src/frontend/index.js

It doesn't work

When I follow the instructions, it displays an empty page in my browser and prints this to the console. I'm using node v4.4.3 on Ubuntu.

ERROR in ./app/components/style.scss
Module build failed: ModuleBuildError: Module build failed: 
  @import "./colors";
 ^
      Import directives may not be used within control directives or mixins.
      in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
    at DependenciesBlock.onModuleBuildFailed (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at Object.onRender (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/index.js:272:13)
    at /home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:906:35
    at _arrayEach (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:85:13)
    at Object.<anonymous> (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:898:17)
    at Object.callback (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:44:16)
    at options.error (/home/nick/Downloads/react-toolbox-example/node_modules/node-sass/lib/index.js:274:32)
 @ ./app/components/header.jsx 19:13-31

ERROR in ./app/style.scss
Module build failed: ModuleBuildError: Module build failed: 
  @import "./colors";
 ^
      Import directives may not be used within control directives or mixins.
      in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
    at DependenciesBlock.onModuleBuildFailed (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at Object.onRender (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/index.js:272:13)
    at /home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:906:35
    at _arrayEach (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:85:13)
    at Object.<anonymous> (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:898:17)
    at Object.callback (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:44:16)
    at options.error (/home/nick/Downloads/react-toolbox-example/node_modules/node-sass/lib/index.js:274:32)
 @ ./app/index.jsx 23:13-31

ERROR in ./~/react-toolbox/lib/button/style.scss
Module build failed: ModuleBuildError: Module build failed: 
  @import "./colors";
 ^
      Import directives may not be used within control directives or mixins.
      in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
    at DependenciesBlock.onModuleBuildFailed (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at Object.onRender (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/index.js:272:13)
    at /home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:906:35
    at _arrayEach (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:85:13)
    at Object.<anonymous> (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:898:17)
    at Object.callback (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:44:16)
    at options.error (/home/nick/Downloads/react-toolbox-example/node_modules/node-sass/lib/index.js:274:32)
 @ ./~/react-toolbox/lib/button/Button.js 39:13-31

ERROR in ./~/react-toolbox/lib/app_bar/style.scss
Module build failed: ModuleBuildError: Module build failed: 
  @import "./colors";
 ^
      Import directives may not be used within control directives or mixins.
      in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
    at DependenciesBlock.onModuleBuildFailed (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at Object.onRender (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/index.js:272:13)
    at /home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:906:35
    at _arrayEach (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:85:13)
    at Object.<anonymous> (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:898:17)
    at Object.callback (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:44:16)
    at options.error (/home/nick/Downloads/react-toolbox-example/node_modules/node-sass/lib/index.js:274:32)
 @ ./~/react-toolbox/lib/app_bar/AppBar.js 19:13-31

ERROR in ./~/react-toolbox/lib/ripple/style.scss
Module build failed: ModuleBuildError: Module build failed: 
  @import "./colors";
 ^
      Import directives may not be used within control directives or mixins.
      in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
    at DependenciesBlock.onModuleBuildFailed (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at /home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at context.callback (/home/nick/Downloads/react-toolbox-example/node_modules/webpack/node_modules/webpack-core/lib/NormalModuleMixin.js:148:14)
    at Object.onRender (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/index.js:272:13)
    at /home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:906:35
    at _arrayEach (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:85:13)
    at Object.<anonymous> (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:898:17)
    at Object.callback (/home/nick/Downloads/react-toolbox-example/node_modules/sass-loader/node_modules/async/lib/async.js:44:16)
    at options.error (/home/nick/Downloads/react-toolbox-example/node_modules/node-sass/lib/index.js:274:32)
 @ ./~/react-toolbox/lib/ripple/Ripple.js 35:13-31
Child extract-text-webpack-plugin:

    ERROR in ./~/css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./~/postcss-loader!./~/sass-loader?sourceMap!./~/toolbox-loader!./app/components/style.scss
    Module build failed: 
      @import "./colors";
     ^
          Import directives may not be used within control directives or mixins.
          in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
Child extract-text-webpack-plugin:

    ERROR in ./~/css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./~/postcss-loader!./~/sass-loader?sourceMap!./~/toolbox-loader!./app/style.scss
    Module build failed: 
      @import "./colors";
     ^
          Import directives may not be used within control directives or mixins.
          in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
Child extract-text-webpack-plugin:

    ERROR in ./~/css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./~/postcss-loader!./~/sass-loader?sourceMap!./~/toolbox-loader!./~/react-toolbox/lib/button/style.scss
    Module build failed: 
      @import "./colors";
     ^
          Import directives may not be used within control directives or mixins.
          in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
Child extract-text-webpack-plugin:

    ERROR in ./~/css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./~/postcss-loader!./~/sass-loader?sourceMap!./~/toolbox-loader!./~/react-toolbox/lib/app_bar/style.scss
    Module build failed: 
      @import "./colors";
     ^
          Import directives may not be used within control directives or mixins.
          in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
Child extract-text-webpack-plugin:
    chunk    {0} extract-text-webpack-plugin-output-filename 2.39 kB [rendered]
        [0] ./~/css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./~/postcss-loader!./~/sass-loader?sourceMap!./~/toolbox-loader!./~/react-toolbox/lib/app/style.scss 884 bytes {0} [built]
        [1] ./~/css-loader/lib/css-base.js 1.51 kB {0} [built]
Child extract-text-webpack-plugin:

    ERROR in ./~/css-loader?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!./~/postcss-loader!./~/sass-loader?sourceMap!./~/toolbox-loader!./~/react-toolbox/lib/ripple/style.scss
    Module build failed: 
      @import "./colors";
     ^
          Import directives may not be used within control directives or mixins.
          in /home/nick/Downloads/react-toolbox-example/node_modules/react-toolbox/lib/_base.scss (line 4, column 3)
webpack: bundle is now VALID.

It can also emit these warnings:

npm WARN optional Skipping failed optional dependency /webpack/watchpack/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

Fails to install modules correctly

I cloned the repo, and started npm install but was met with this error message at the end of the install process.

`npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v6.1.0
npm ERR! npm v3.8.6
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: node scripts/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node scripts/build.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node scripts/build.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\eladk\Documents\GitHub\react-toolbox-example\npm-debug.log`

I attempted to npm start but was then met with this error: Error: Cannot find module 'brace-expansion'

I installed it, and re-ran npm start and still no luck:
`ERROR in .//react-toolbox/lib/app_bar/style.scss
Module build failed: Error: Cannot find module 'node-sass'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\eladk\Documents\GitHub\react-toolbox-example\node_modules\sass-loader\index.js:4:12)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
@ ./
/react-toolbox/lib/app_bar/AppBar.js 15:13-31

'ERROR in .//react-toolbox/lib/ripple/style.scss
Module build failed: Error: Cannot find module 'node-sass'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\eladk\Documents\GitHub\react-toolbox-example\node_modules\sass-loader\index.js:4:12)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
@ ./
/react-toolbox/lib/ripple/Ripple.js 23:13-31`

Can't build with cross-env - Error: spawn webpack ENOENT

Cloned repo, ran install, ran start - works fine. Ran build - get this error:

λ npm run build

> [email protected] build C:\...\react-toolbox-example
> cross-env NODE_ENV=production UV_THREADPOOL_SIZE=100 webpack --config ./webpack.config.file

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: spawn webpack ENOENT
    at exports._errnoException (util.js:837:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)
    at Function.Module.runMain (module.js:477:11)
    at startup (node.js:117:18)
    at node.js:951:3

npm ERR! Windows_NT 10.0.10240

So I tried to set node env manually

SET NODE_ENV=production && webpack --config ./webpack.config.file

But it didn't work or something, because the built react-toolbox.js file will still look for __webpack_hmr EventSource, so hmr appears to be still enabled.

The problem also appears in my actual project, that I used react-toolbox in. I eliminated any trace of hmr from my source files yet it still kept showing up - turns out it was from the source of react-toolbox. So how do I let it know that the "node env" is "production"?

Also tried to do it in the webpack.config.file.js file

'process.env.NODE_ENV': JSON.stringify('production')

Nothing changed.

npm start, webpack build memory usage exceeds 500MB

This is more of discussion rather than issue report.
Is there a suggested way to decrease the memory usage while the webpack is building? Just to run this example, even in NODE_ENV=production, memory usage exceeds 550MB. Once the build is complete, of course, it drops to ~25MB.
I have a problem deploying a small test app to Heroku, as they're only providing me with 512MB and build exceeds 10s while it switches over to swap space.

Please, any hint is appreciated! Great project.

Can't get to work with react-slingshot

I am trying to use react-toolbox with the react-slingshot starter kit. I installed react-toolbox and was trying to use the demo code for the Button component from the react-toolbox site and it didn't work. The buttons icons are not showing up, so I tried to update the webpack config to make it look similar to the one here. Got a whole bunch of errors. Can somebody give it a shot and let me know what needs to be done to make it work? thanks.

npm install with Node.js v6.10.2 (npm3 v3.10.10)

I'm installing react-toolbox-example in a workspace of Cloud9.
I'm using Node.js v6.10.2 (npm3 v3.10.10). On the install I get this messages:

UNMET PEER DEPENDENCY [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── UNMET PEER DEPENDENCY [email protected]
├── UNMET PEER DEPENDENCY [email protected]
etc..
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── UNMET PEER DEPENDENCY redux@^3.1.0
etc..
//and continues without more UNMET messages.

And in the end I get:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] requires a peer of react@^0.14 || ~15.4.0 but none was installed.
npm WARN [email protected] requires a peer of react-addons-css-transition-group@^0.14.0 || ~15.4.0 but none was installed.
npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ~15.4.0 but none was installed.
npm WARN [email protected] requires a peer of redux@^3.1.0 but none was installed.

Then, I start with npm start and I get:

username:~/workspace (master) $ npm start

[email protected] start /home/ubuntu/workspace
cross-env NODE_ENV=development node_modules/.bin/webpack-dev-server --colors --config webpack.config.js

Project is running at http://localhost:8080/
webpack output is served from http://localhost:8080/
Content not from webpack is served from /home/ubuntu/workspace/src/www
404s will fallback to /index.html
(node:2817) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see webpack/loader-utils#56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: 3c9493796afc42412ba3
Version: webpack 2.3.3
Time: 50931ms
Asset Size Chunks Chunk Names
bundle.js 10.1 MB 0 [emitted] [big] bundle
chunk {0} bundle.js (bundle) 3.16 MB [entry] [rendered]
[./node_modules/react-dom/index.js] .//react-dom/index.js 164 bytes {0} [built]
[./node_modules/react-hot-loader/patch.js] ./
/react-hot-loader/patch.js 146 bytes {0} [built]
[./node_modules/react-toolbox/lib/index.js] .//react-toolbox/lib/index.js 7.18 kB {0} [built]
[./node_modules/react/react.js] ./
/react/react.js 161 bytes {0} [built]
[./node_modules/strip-ansi/index.js] .//strip-ansi/index.js 379 bytes {0} [built]
[./node_modules/url/url.js] ./
/url/url.js 25.4 kB {0} [built]
[./node_modules/webpack-dev-server/client/index.js?http:/localhost:8080] (webpack)-dev-server/client?http://localhost:8080 8.29 kB {0} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 5.28 kB {0} [built]
[0] multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch ./src/frontend/index.js 64 bytes {0} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.33 kB {0} [built]
[./node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js 1.99 kB {0} [built]
[./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 180 bytes {0} [built]
[./node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js 1.1 kB {0} [built]
[./src/frontend/component/App.js] ./src/frontend/component/App.js 1.02 kB {0} [built]
[./src/frontend/index.js] ./src/frontend/index.js 999 bytes {0} [built]
+ 742 hidden modules
webpack: Compiled successfully.

What it means?

Not able to find output file

Hi,
I got your example working, just had a question.
Where is the output stored?
It says in the config that it is in build folder, but i cannot find any build folder :/

Does not work when multiple modules are exported - the generated css is blank

const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
const AUTOPREFIXER_BROWSERS = [
'Android 2.3',
'Android >= 4',
'Chrome >= 35',
'Firefox >= 31',
'Explorer >= 9',
'iOS >= 7',
'Opera >= 12',
'Safari >= 7.1'
];

var debug = process.env.NODE_ENV !== "production";

module.exports = {
context: dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: {
"moduleA": "./src/moduleA/index.js",
"moduleB": "./src/moduleB/index.js"
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].bundle.js',
publicPath: '/'
},
resolve: {
extensions: ['', '.scss', '.css', '.js', '.json']
},
module: {
loaders: [
{
test: /(.js)|(.jsx)$/,
exclude: /(node_modules)/,
loader: 'babel',
query: {
presets: ['es2015', 'react'],
plugins: ['jsx-control-statements']
}
},
{
test: /(.scss|.css)$/,
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]
[local]___[hash:base64:5]!postcss!sass')
}
]
},
postcss: [autoprefixer({browsers: AUTOPREFIXER_BROWSERS})],
sassLoader: {
data: '@import "theme/_config.scss";',
includePaths: [path.resolve(__dirname)]
},
externals: {
'react': 'React',
'react-dom': 'ReactDOM',
'react-addons-css-transition-group': 'React.addons.CSSTransitionGroup'
},
plugins: debug ? [new ExtractTextPlugin('main.css', { allChunks: true })] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
mangle: false, sourcemap: false, screw_ie8: true,
warnings: false
})
]
};

webpack build output is main.css 195 bytes 0, 2, 7 [emitted] moduleA, moduleB

SyntaxError cropped up

suddenly now giving an error:

ERROR in ./~/react-toolbox/components/index.js
Module build failed: SyntaxError: D:/Documents/react-toolbox-example-master/node_modules/react-toolbox/components/index.js: Unexpected token, expected { (24:7)

Steps to duplicate: exactly the same as the steps in the README.

start error?

app.get('*', (req, res) => {
^^
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3

How do I add an images folder to the build?

  • webpack.config.js file
const path = require('path');
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractPlugin = new ExtractTextPlugin({
  filename: 'main.css'
});
const HTMLWebpackPlugin = require('html-webpack-plugin');
const htmlplugin = new HTMLWebpackPlugin({
      template: 'src/www/index.html'
      // baseUrl: './'
    });
const settings = {
  entry: {
    bundle: [
      'react-hot-loader/patch',
      './src/frontend/index.js'
    ]
  },
  output: {
    filename: '[name].js',
    publicPath: '',
    path: path.resolve('build')
  },
  resolve: {
    extensions: ['.js', '.json', '.css']
  },
  devtool: 'eval-source-map',
  module: {
    rules: [
      {
        test: /\.html$/,
        use: ['html-loader']
      },
      {
        test: /\.js?$/,
        loader: 'babel-loader',
        options: {
          presets: [
            ['es2015', { modules: false }],
            'stage-2',
            'react'
          ],
          plugins: [
            'transform-node-env-inline'
          ],
          env: {
            development: {
              plugins: ['react-hot-loader/babel']
            }
          }
        }
      },
      {
        test: /\.sass$/,
        use: extractPlugin.extract({
          use: [{
            loader: 'css-loader',
            options: {
              minimize: true
            }
          },
          'sass-loader']
        })
      },
      {
        test: /\.(jpg|png)$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: '[name].[ext]',
              outputPath: 'img/',
              publicPath: 'img/'
            }
          }
        ]
      },
      {
        test: /\.(css)$/,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              modules: true,
              sourceMap: true,
              importLoaders: 1,
              localIdentName: '[name]--[local]--[hash:base64:8]'
            }
          },
          'postcss-loader' // has separate config, see postcss.config.js nearby
        ]
      }
    ]
  },
  devServer: {
    contentBase: path.resolve('src/www'),
    publicPath: 'http://localhost:8080/', // full URL is necessary for Hot Module Replacement if additional path will be added.
    quiet: false,
    hot: true,
    historyApiFallback: true,
    inline: true
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NamedModulesPlugin(),
    new webpack.LoaderOptionsPlugin({
      debug: true
    }),
    htmlplugin,
    extractPlugin,
    new CleanWebpackPlugin(['build'])
  ]
};

module.exports = settings;



I have an image folder in my src....
But img folder is not getting created in my build folder and there is no error to debug
HELP!!

Ripple tag won't be removed

The ripple tag won't be removed after clicking button.
I found that the ripple tag won't be removed in my project.
But it can't be reproduced on react-toolbox web page example.
So I try it on react-toolbox-example, and it happens.
As below snapshot, I click the SuccessButton in react-toolbox-example.<span data-react-toolbox="ripple" class="theme__rippleWrapper___2AWhQ theme__rippleWrapper___2zthi"></span> tag should be removed but it won't.
2016-10-25 7 02 36

Tabs not showing on react-toolbox-example

Hello. I installed the react-toolbox-example project and was able to use all the components without any problems. All of them except for the "Tabs" component.
This component simply doesn't show.
See this trivial App.js:

import React from 'react';
import { Button } from 'react-toolbox/lib/button';
//import { Tab, Tabs } from 'react-toolbox';
import { Tabs, Tab } from "react-toolbox/lib/tabs";

class App extends React.Component {
  state = {
    index: 0
  };
  setIndex = index => {
    this.setState({ index });
  };
  render() {
    return (
      <div>
        <div>[Tabs - start]</div>
        <Tabs index={this.state.index} onChange={this.setIndex}>
          <Tab label='Primary'><small>Primary content</small></Tab>
          <Tab label='Secondary' onActive={this.handleActive}><small>Secondary content</small></Tab>
          <Tab label='Third' disabled><small>Disabled content</small></Tab>
          <Tab label='Fourth' hidden><small>Fourth content hidden</small></Tab>
          <Tab label='Fifth'><small>Fifth content</small></Tab>
        </Tabs>
        <div>[Tabs - end]</div>
        <Button label='Click on me!' raised primary />
      </div>
    );
  }
}

export default App;

All I get on the screen is something like:

[Tabs - start]
[Tabs - end]

   Click on me!

The Tabs and Tab objects are imported alright I think (at least they are not null). I tried to import them in 2 different ways (see code above) but the result is the same on both cases.
I want to point out the fact that any other component I tried it worked without any issues (and I tried almost all of them!)
Any ideas?
Alex

ModuleNotFoundError on ~normalize.css

Following the exact same instructions of the README:

Module build failed: ModuleNotFoundError: Module not found: Error: Cannot resolve module '~normalize.css'

image

It happens when navigating to http://0.0.0.0:8080/ and a blank page is displayed.

Small workaround to "make it work":

image

Node v4.5.0

Error on clone, install, start

After git clone, npm install, npm start...I get this error:

> [email protected] start /home/..../react-toolbox-example
> node server

..../react-toolbox-example/server.js:22
app.get('*', (req, res) => {
                         ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

npm ERR! Linux 3.13.0-95-generic
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.10.25
npm ERR! npm  v3.10.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `node server`
npm ERR! Exit status 8

Ubuntu 14.04/NPM 3.10.7

Cannot start

Hi guys, I found react toolbox quite interesting so I decided to give it a try. Unfortunately I'm unable to start it. Tried node version 4.2.3 and 5.3.0 but both are stuck on npm start (npm run build is fine, deploy gives error). I'm attaching the log so you can have a look at it.
npm-debug.txt

Webpack hot module replacement

First of all, thank you for this example. I struggled making react-toolbox work.

Is it possible to add webpack hot module replacement or another kind of auto app refresh on code change?

Compiling slow

Why is compiling so slow? I'm testint the react-toolbox-example on my local machine through a virtual machine, I usually compile apps there within 0,2 -2 seconds at max, same in Cloud9, but with this example, a simple change in the code takes like 130-250 seconds to finish the compile process, both in my virtual machine and in Cloud9. Other apps in Cloud9, with bundles.js with size of 2MB compiles fast, no more than 1-2seconds.

Cannot resolve module 'style'

Hmmmm... I am using webpack for two different sections (based on the configuration of this repository) of my application (main and admin). The endpoint admin wont start because each react-toolbox component (e.g. face as showed below).

ERROR in ./~/react-toolbox/lib/time_picker/clock/face.js
Module not found: Error: Cannot resolve module 'style' in /PATH/TO/MY/PROJECT/node_modules/react-toolbox/lib/time_picker/clock
 @ ./~/react-toolbox/lib/time_picker/clock/face.js 29:13-31

The configuration looks like this:

// core/webpack/config.js
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = function generateConfig(endpoint) {
    var dirname = `${process.cwd()}/core/resource/app/${endpoint}`;

    return {
        context: dirname,
        devtool: 'inline-source-map',
        entry: [
            'webpack-hot-middleware/client',
            path.join(dirname, 'src', 'bootstrap')
        ],
        output: {
            path: path.join(dirname, '../../static/app'),
            filename: `${endpoint}.js`,
            publicPath: '/app'
        },
        plugins: [
            new webpack.HotModuleReplacementPlugin(),
            new webpack.NoErrorsPlugin(),
            new ExtractTextPlugin('react-toolbox.css', { allChunks: true })
        ],
        module: {
            loaders: [
                {
                    test: /(\.js|\.jsx)$/,
                    exclude: /(node_modules)/,
                    loader: 'babel'
                },
                {
            test: /(\.scss|\.css)$/,
            loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap!toolbox')
          }
            ]
        },
        resolve: {
            extensions: ['', '.jsx', '.scss', '.js', '.json'],
            modulesDirectories: [
                'node_modules',
                `${process.cwd()}/node_modules`
            ]
        },
        postcss: [autoprefixer]
    };
};

// core/resource/app/main/config.js
var webpack = require('../../../webpack/config');

module.exports = webpack('admin');

Any idea?

Stylesheet seems to be loaded after the bundle?

When I view the page, it seems to flash with the toolbox logo (very large, black colored, on a white page background), and then after that it goes to the expected view.

Is there a way to make it load correctly on first page load?

roboto-font and material-icons

Can you please show us an example how to load roboto-font and material-icons through webpack modules without using link ref tag?

It seems there are conflict with sass-loader and toolbox-loader when bundling roboto-font and material-icons together. An example with that would be greatly appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.