carteb / carte-blanche

An isolated development space with integrated fuzz testing for your components. See them individually, explore them in different states and quickly and confidently develop them.
https://www.youtube.com/watch?v=6g3-TQ6aaw8
MIT License
1.5k stars 47 forks source link

dest option not working as expected #286

Closed Anahkiasen closed 8 years ago

Anahkiasen commented 8 years ago

I tried boiling down my test to the bare minimum but I still can't seem to get this to work, is there anything I'm doing wrong here?

webpack.config.js

var CarteBlanche = require('carte-blanche');
var path = require('path');

module.exports = {
    entry: './src/js/client.js',
    output: {
        path: 'dist',
        filename: 'main.js',
    },
    plugins: [
        new CarteBlanche({
            componentRoot: './src/js/Components',
            filter: /CategoryIcon\.js/,
        }),
    ],
    module: {
        loaders: [
            {
                test: /\.js$/,
                include: path.resolve('src/js'),
                loader: 'babel',
            },
        ],
    },
};

CategoryIcon.js

import React from 'react';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';

const CategoryIcon = ({icon}) => <Glyphicon glyph={icon} />;

CategoryIcon.propTypes = {
    icon: React.PropTypes.string.isRequired,
};

export default CategoryIcon;

.babelrc

{
    "presets": ["es2015","stage-0","react"],
    "plugins": ["transform-decorators-legacy"]
}

This is what I get when I compile:

$ webpack
Variation server listening at localhost:8082

Hash: c984de3200651618229c
Version: webpack 1.13.1
Time: 10412ms
                                 Asset       Size  Chunks             Chunk Names
  f4769f9bdb7466be65088239c12046d1.eot    20.1 kB          [emitted]
448c34a56d699c29117adc64c43affeb.woff2      18 kB          [emitted]
 fa2772327f55d8198301fdb8bcfc8158.woff    23.4 kB          [emitted]
  e18bbf611f2a2e43afc071aa2f4e1512.ttf    45.4 kB          [emitted]
  89889688147bd7575d6327160d64e760.svg     109 kB          [emitted]
          carte-blanche/user-bundle.js    2.87 MB       0  [emitted]  CarteBlanche [0]
                               main.js    3.19 MB       1  [emitted]  main
              carte-blanche/index.html  374 bytes          [emitted]
        carte-blanche/client-bundle.js    1.08 MB          [emitted]
       carte-blanche/client-bundle.css    5.22 kB          [emitted]
   [0] multi CarteBlanche [0] 28 bytes {0} [built]
   [3] ./src/js/Components CategoryIcon\.js 182 bytes {0} [built]
    + 1472 hidden modules

WARNING in ./~/faker/build/build/faker.js
Critical dependencies:
1:436-443 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 @ ./~/faker/build/build/faker.js 1:436-443

I can see the files in /dist/carte-blanche but when I go to http://localhost:8082/ or http://localhost:8082/carte-blanche/ all I get is Cannot GET /

mxstbr commented 8 years ago

We shouldn't be outputting the localhost:8082 line, that's where we run our Node.js server!

Instead, go to where ever you run your local server (e.g. localhost:8080/carte-blanche) and it's going to work!

Anahkiasen commented 8 years ago

@mxstbr Yes and no, it's generating the HTML with paths such as /carte-blanche/client-bundle.css but in my case the files are output in /dist/carte-blanche so the paths are incorrect. If I change the dest option to /dist/carte-blanche then it just generates them in /dist/dist/carte-blanche.

Additionally I'm using HMR on my Express server like documented:

const config = require('../../webpack.config');
const compiler = require('webpack')(config);

app.use(require('webpack-dev-middleware')(compiler));
app.use(require('webpack-hot-middleware')(compiler));

But since CB is blocking (ie if I run webpack it never stops) the server also gets stuck there, is this expected behavior?

The only way to get it to work currently is to comment out the HMR on the server and edit the paths in the generated HTML

mxstbr commented 8 years ago

Oh no, that's definitely a bug, our bad, that should definitely not be the case! Let me reopen this and we'll look into it!

Anahkiasen commented 8 years ago

Actually strike that, editing the paths in the HTML doesn't work, I mean Carte Blanche works but none of the components show up, it seems to still be pinging the old path:

screen shot 2016-06-03 at 14 47 37

Making the paths relative should work maybe? Like src="user-bundle.js" that way no matter where CB is exported to, if you can access it, it can access its own files.

jarrydfillmore commented 8 years ago

+1, same thing is happening to me too!

mxstbr commented 8 years ago

Yeah the bug seems to be somewhere along the piping of the dest option, will take a look asap!

nikgraf commented 8 years ago

Working on this right now …