我在我的Storybook配置目录.storybook
中使用了自定义Webpack配置文件,运行命令start-stroybook
后,我的页面上出现了exports is not defined
错误。
以下是自定义Webpack配置文件的内容:
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
plugins: [
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
__IS_NATIVE__: JSON.stringify(false),
'process.env.NODE_ENV': JSON.stringify('development'),
}),
],
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
},
exclude: path.join(__dirname, '../node_modules'),
},
{
test: /\.svg$/,
issuer: /\.js$/,
use: [
{
loader: 'babel-loader',
},
() => {
this.counter = this.counter || 0;
return {
loader: 'react-svg-loader',
options: {
jsx: true,
svgo: {
plugins: [
{
cleanupIDs: {
prefix: `${this.counter++}`,
},
},
],
},
},
};
},
],
},
{
test: /\.svg$/,
issuer: /\.css$/,
use: 'svg-url-loader',
},
{
test: /\.((png)|(eot)|(woff)|(ttf)|(gif)|(jpg)|(otf))$/,
use: 'url-loader?name=/[hash].[ext]',
},
{
test: /\.ico$/,
use: 'file-loader',
},
{
test: /\.json$/,
use: 'json-loader',
},
{
test: /\.css$/,
exclude: /node_modules/,
use: [
'style-loader',
'css-loader?modules&importLoaders=1' +
'&sourceMap?&localIdentName=[path]-[local]-[hash:base64:5]',
'postcss-loader',
],
},
],
},
resolve: {
modules: ['node_modules', 'pretend_modules'],
},
};
Storybook的版本以及我正在运行的任何受影响的附加组件: