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

Fix ReactPlugin files option properly #257

Open mxstbr opened 8 years ago

mxstbr commented 8 years ago

        const assets = this.options.files;
        if (assets.length > 0) {
          setTimeout(() => {
            renderToClient({
              // TODO the name is used in the iframe & playground list
              // best to pass it in there instead of hardcoding it
              name: 'react',
              frontendData: new Promise((resolve, reject) => {
                readMultipleFiles(assets, (err, contents) => {
                  if (err) {
                    reject(err);
                  }
                  const scripts = [];
                  const styles = [];
                  // Depending on the asset type that was passed add them to a script
                  // or style tag
                  assets.forEach((assetFilename, index) => {
                    switch (assetFilename.substr(-3)) {
                      case '.js': scripts.push(contents[index]); break;
                      case 'css': styles.push(contents[index]); break;
                      default: break;
                    }
                  });
                  resolve({ options, files: { scripts, styles } });
                });
              }),
              frontendPlugin: `${require.resolve('./frontend/index.js')}`,
            });
          }, 5);
        }
nikgraf commented 8 years ago

@mxstbr what is this about?