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

Full Control Webpack Breaks Loaders #390

Closed
michaelryancaputo opened this issue Aug 19, 2016 · 1 comment
Closed

Full Control Webpack Breaks Loaders #390

michaelryancaputo opened this issue Aug 19, 2016 · 1 comment

Comments

@michaelryancaputo
Copy link

michaelryancaputo commented Aug 19, 2016

I'm trying to load in some environment variables into my storybook using the webpack full control method.

my webpack.config.js file looks like this:

var webpack = require ('webpack');

module.exports = (storybookBaseConfig, configType) => {
  storybookBaseConfig.plugins.push (
    new webpack.DefinePlugin ({
      'process.env.client_id': JSON.stringify (process.env.client_id),
    })
  );
  return storybookBaseConfig;
};

When I do this, I seem to loose all of my loaders, css won't load. Also, i can't seem to load in webpack with es6 syntax import webpack from 'webpack'.

@michaelryancaputo
Copy link
Author

Managed to get this working, with some help from #155

My webpack config:

require('babel-register');
module.exports = require('./webpack.config.babel.js');

webpack.config.babel.js

import webpack from 'webpack';
import path from 'path';

module.exports = (storybookBaseConfig, configType) => {

  storybookBaseConfig.plugins.push (
    new webpack.DefinePlugin ({
      'process.env.client_id': JSON.stringify (process.env.client_id),
    })
  );

  storybookBaseConfig.module = {
    loaders: [
      {
        test: /\.(js|jsx)$/,
        loader: `babel-loader`,
        exclude: /(node_modules)/,
        query: {
          presets: ['react', 'es2015', 'stage-0'],
          babelrc: false
        }
      },
      {
        loader: 'url-loader?limit=10000',
        test: /\.(gif|jpg|png|svg)$/,
        include: path.resolve (__dirname, '../')
      }, {
        loader: 'url-loader?limit=1',
        test: /favicon\.ico$/,
        include: path.resolve (__dirname, '../')
      }, {
        loader: 'url-loader?limit=100000',
        test: /\.(ttf|eot|woff(2)?)(\?[a-z0-9]+)?$/,
        include: path.resolve (__dirname, '../')
      },
      {
        loader: 'style-loader!css-loader',
        test: /\.css$/,
        include: path.resolve (__dirname, '../'),
        exclude: path.resolve (__dirname, '../node_modules')
      },
      {
        loader: 'style-loader!css-loader!sass-loader',
        test: /\.scss$/,
        include: path.resolve (__dirname, '../'),
        exclude: path.resolve (__dirname, '../node_modules')
      },
    ],
    sassLoader: {
      includePaths: path.resolve (__dirname, '../src/browser')
    },
  };

  return storybookBaseConfig;
};

.babelrc

{
  "presets": ["es2015", "react", "stage-0"]
}

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

1 participant