Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module build failed: Error: composition is only allowed when selector is single :local class name not in ".raised", ".raised" is weird #1444

Closed
burakuluu opened this issue May 4, 2017 · 3 comments

Comments

@burakuluu
Copy link

Hi,

I tried to use react-toolbox but this error keeps showing after all the solutions that I've found. I finally decided to ask here.

Error is;

Module build failed: Error: composition is only allowed when selector is single :local class name not in ".raised", ".raised" is weird

My postcss.config.js file looks like;

module.exports = {
  plugins: [
    require('postcss-smart-import')({ /* ...options */ }),
    require('precss')({ /* ...options */ }),
    require('autoprefixer')({ /* ...options */ })
  ]
}

In my .js file, I imported some react-toolbox modules;

import AppBar from 'react-toolbox/lib/app_bar';
import Navigation from 'react-toolbox/lib/navigation';

And also my webpack.config.dev.js and webpack.config.prod.js look like;

var webpack = require('webpack');
var loaders = require('./webpack.loaders');
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  context: path.join(__dirname, "src"),
  devtool: 'inline-sourcemap',
  entry: {
    app: "./app.js",
    vendor: [
      'axios',
      'react',
      'react-dom',
      'react-grid-layout',
      'react-bootstrap',
      'react-redux',
      'react-router',
      'redux',
      'redux-logger',
      'redux-thunk'
    ]
  },
  resolve: {
    root: path.resolve(__dirname),
    alias: {
      'dashboard-app/config': 'src/config',
      'dashboard-app/utils': 'src/utils',
      'dashboard-app/auth': 'src/modules/auth',
      'dashboard-app/dashboard-view': 'src/modules/dashboard-view',
      'dashboard-app/header': 'src/modules/header',
      'dashboard-app/widgets-container': 'src/modules/widgets-container',
      'dashboard-app/assets': 'src/assets',
    },
    extensions: ['', '.js', '.jsx']
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: ['babel-loader'],
        query: {
          presets: ['react', 'es2015', 'stage-0'],
          plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
        }
      },
      {
        test: /\.css$/,
        loader: 'style!css!postcss'
      },
      {
        test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
        loader: "file"
      },
      {
        test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url?prefix=font/&limit=5000"
      },
      {
        test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url?limit=10000&mimetype=application/octet-stream"
      },
      {
        test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
        loader: "url?limit=10000&mimetype=image/svg+xml"
      },
      {
        test: /\.gif/,
        loader: "file?name=./images/[sha512:hash:base64:7].[ext]"
      },
      {
        test: /\.jpg/,
        loader: "file?name=./images/[sha512:hash:base64:7].[ext]"
      },
      {
        test: /\.png/,
        loader: "file?name=./images/[sha512:hash:base64:7].[ext]"
      }
    ]
  },
  output: {
    path: path.join(__dirname, 'dist'),
    filename: "/[name]-[hash].js"
  },
  plugins: [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.CommonsChunkPlugin("vendor", "/[name]-[hash].js"),
    new HtmlWebpackPlugin({
      template: __dirname + "/src/index.tmpl.html"
    }),
  ],
};
@burakuluu
Copy link
Author

My problem has been solved by utilizing these solutions;

npm install postcss-loader --save-dev
npm install postcss --save
npm install postcss-cssnext --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',
        ],
      },

@yarnball
Copy link

yarnball commented May 17, 2017

I'm also having this problem. Is this the only solution? Has not worked for me. Your webpack code gives me an error

javivelasco pushed a commit that referenced this issue Aug 2, 2017
* update webpack config to make "Basic usage" work.

I use webpack version 2.6 and new configure syntax rather than 1.x.

When I follow the instruction on `readme.md`. It always failed on *Basic Usage* with the message below.
``` bash
ERROR in ./~/css-loader?{"modules":false,"importLoaders":1,"localIdentName":"[name]--[local]--[hash:base64:8]"}!./~/postcss-loader/lib!./~/react-toolbox/lib/button/theme.css
  Module build failed: Error: composition is only allowed when selector is single :local class name not in ".raised", ".raised" is weird
```

So I figured out what's wrong and update `reame.md` to notify others.

* edit multiple number.

According to docs, the width is larger than 320px and if the device is mobile than 280px. To follow this specification It should be 5, not 4.
javivelasco added a commit that referenced this issue Aug 8, 2017
* 'dev' of github.com:soyjavi/react-toolbox: (24 commits)
  Fix bug where dropdowns don't close (#1548)
  Fix Mobile Safari issues. (#1282)
  Feature/tabs a11y (#1513)
  Add default export TypeScript type to IconButton (#1577)
  Add variables for the App Bar's font size and weight. (#1518)
  Change tab style for ripple to work with Tabs (#1519)
  Issue 1459: Replace onClick handler in Dropdown component to onMouseDown (#1521)
  Event passed for Radiogroup (#1544)
  Add `accept` property to `BrowseButton` (#1533)
  Fix typescript bindings. (#1564)
  fixed browser button fires onChange event  twice (#1557)
  Made role on input field a property (#1553)
  Add workaround to `is-component-of-type` for `react-hot-loader@^3` (#1569)
  Docs/Install: Fix typos, clarify language (#1566)
  Add ThemeProvider Typescript type (#1576)
  Apply padding 0 to everything but buttons in ListItemAction (#1571)
  Do not show scrollbar on autocomplete component IE11 (#1515)
  Fix date-picker animation in IE11 (#1586)
  solve #1444 and #1359. (#1587)
  Remove discord link in README.md (#1593)
  ...
@Karivool
Copy link

Karivool commented Oct 6, 2017

I just wanted to say thank you for posting this solution @burakuluu - this helped me finally compile webpack after so many other failed solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants