question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In prod mode with ExtractTextPlugin, my styles import returns an array of values.

See original GitHub issue

In development mode, I don’t seem to have any issues running the application. The styles are loaded by javascript and the variables are available as objects for require styles, the way css-modules intended me to use it.

{ headerTitle: 'headerTitle___1VPCU', _style: '.headerTitle___1VPCU {\n color: #c51d23;\n font-size: 1.167em;\n font-weight: 700;\n text-transform: uppercase;\n padding: 18% 1% 1% 1%;\n text-align: center;\n}' }

The problem I run into is is production mode. My import returns an array set containing path information of the required style file, followed with the contents of the style file converted by postcss.

[ [ '/Users/shouvik/Documents/dream11/pandora/client/containers/MatchCenter/style.css.webpack-module', '.headerTitle___1VPCU{color:#c51d23;font-size:1.167em;font-weight:700;text-transform:uppercase;padding:18% 1% 1%;text-align:center}', '' ] ]

I am not sure where exactly am I going wrong when it comes to configuring my webpack.

For the webpack-isomorphic-tools.js, I have reused the code written here. For my webpack config I do this:

module.exports = {
  context: path.resolve(__dirname, '..'),
  entry: {
    jsx: './client/index.js',
    html: './client/index.html',
    vendor: [
      'react',
      'react-dom',
      'react-redux',
      'react-router',
      'react-router-redux',
      'redux'
    ]
  },
  output: {
    path: assetsPath,
    filename: 'bundle.js',
  },
  module: {
    loaders: [
      {
        test: /\.html$/,
        loader: 'file?name=[name].[ext]'
      },
      {
        test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/,
        loader: 'url-loader?limit=100000'
      },
      {
        test: /\.css$/,
        include: /client/,
        loaders: (
          () => {
            if (isDevelopment) {
             return [
              'style-loader',
              'css-loader?modules&sourceMap&importLoaders=1&localIdentName=[local]___[hash:base64:5]',
              'postcss-loader'
            ] } else return [
              ExtractTextPlugin.extract('style-loader', 'css-loader'),
              'css-loader?modules&importLoaders=2&localIdentName=[local]___[hash:base64:5]',
              'postcss-loader'
            ]
          }
        )()
      },
      {
        test: /\.css$/,
        exclude: /client/,
        loader: 'style!css'
      },
      {
        test: /\.(js|jsx)$/,
        exclude: /node_modules/,
        loaders: [
          'react-hot',
          'babel-loader'
        ]
      }
    ],
  },
  resolve: {
    extensions: ['', '.js', '.jsx']
  },
  postcss: [
    values,
    assets({
      basePath : 'client/assets',
      loadPaths: ['images','fonts'],
      relative : true,
      cacheBuster: true
    }),
    rucksack({
      autoprefixer: true
    })
  ],
  plugins: (() => {
    const plugins = [];

    if(isDevelopment) {
      plugins.push(
        new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
        new webpack.DefinePlugin({
          'process.env': { NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development') },
          __CLIENT__: true,
          __SERVER__: false,
          __DEVELOPMENT__: true,
          __DEVTOOLS__: true
        }),
        webpackIsomorphicToolsPlugin.development()
      )
    } else {
      plugins.push(
        new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js'),
        new ExtractTextPlugin('[name]-[chunkhash].css', {allChunks: true}),
        new webpack.DefinePlugin({
          'process.env': { 
            NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development') 
          },
          __CLIENT__: true,
          __SERVER__: false,
          __DEVELOPMENT__: false,
          __DEVTOOLS__: false
        }),
        new webpack.optimize.UglifyJsPlugin({
          compress: {
            warnings: false
          }
        }),
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.OccurenceOrderPlugin(),
        webpackIsomorphicToolsPlugin
      )
    }
    return plugins
  })(),
  devServer: {
    contentBase: '../client',
    hot: true
  }
}


Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
catamphetaminecommented, Oct 19, 2016

You can post the whole file

0reactions
shouvikcommented, Oct 19, 2016

Yep @halt-hammerzeit Thanks a bunch for your time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues - GitHub
I am using extract-text-webpack-plugin in prod mode to put the styles in a single css file and load it on client.
Read more >
Getting css output using webpack ExtractTextPlugin
Using css-loader and style-loader together first parse your CSS, then turn it into style nodes, which can be imported in Webpack just like...
Read more >
ExtractTextWebpackPlugin | webpack
It moves all the required *.css modules in entry chunks into a separate CSS file. So your styles are no longer inlined into...
Read more >
Javascript – Webpack can't load packages from node_modules ...
Javascript – Webpack can't load packages from node_modules. javascriptreactjswebpackwebpack-style-loader. I am starting app with react-slingshot start kit.
Read more >
Lecture: Webpack 4 - SlideShare
From the bottom up, you connect the loader for the language in which you have styles, then you can add postcss for autofix...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found