Skip to content

Commit

Permalink
fix: 修复 stroybook 发布问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Aug 25, 2018
1 parent 6d0ca34 commit 9c67fbe
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 105 deletions.
165 changes: 67 additions & 98 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,76 @@
const path = require("path");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const OpenBrowserPlugin = require('open-browser-webpack-plugin')
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');

module.exports = (storybookBaseConfig, configType) => {
const isDev = configType === "DEVELOPMENT"
const isDev = configType === 'DEVELOPMENT';


storybookBaseConfig.module.rules.push(...[
{
test: /\.less$/,
use:
isDev
? [
{ loader: "style-loader" },
{
loader: "css-loader",
options: {
javascriptEnabled: true,
minimize: false,
sourceMap: true
}
},
{
loader: "postcss-loader",
options: { javascriptEnabled: true, sourceMap: true }
},
{
loader: "less-loader",
options: { javascriptEnabled: true, sourceMap: true }
}
]
: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
"css-loader",
{ loader: "postcss-loader", options: { sourceMap: false } },
{
loader: "less-loader",
options: {
sourceMap: false
}
}
]
})
},
{
test: /\.css$/,
use: isDev
? [
{ loader: "style-loader" },
{
loader: "css-loader",
options: {
javascriptEnabled: true,
minimize: false,
sourceMap: true
}
},
{
loader: "postcss-loader",
options: { javascriptEnabled: true, sourceMap: true }
storybookBaseConfig.module.rules.push(
...[
{
test: /\.less$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
javascriptEnabled: true,
minimize: false,
sourceMap: true
}
},
{
loader: 'postcss-loader',
options: { javascriptEnabled: true, sourceMap: true }
},
{
loader: 'less-loader',
options: { javascriptEnabled: true, sourceMap: true }
}
]
},
{
test: /\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: {
javascriptEnabled: true,
minimize: false,
sourceMap: true
}
]
: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
"css-loader",
{
loader: "postcss-loader",
options: { sourceMap: false }
},
{
loader: "less-loader",
options: {
sourceMap: false
}
}
]
})
},
{
test: /\.(jpg|jpeg|png|gif|cur|ico)$/,
use: [
{
loader: "file-loader",
options: {
name: "images/[name][hash:8].[ext]" //遇到图片 生成一个images文件夹 名字.后缀的图片
},
{
loader: 'postcss-loader',
options: { javascriptEnabled: true, sourceMap: true }
}
}
]
},
{
test: /\.(eot|ttf|svg|woff|woff2)$/,
use: [
{
loader: "file-loader",
options: {
name: "fonts/[name][hash:8].[ext]"
]
},
{
test: /\.(jpg|jpeg|png|gif|cur|ico)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'images/[name][hash:8].[ext]' //遇到图片 生成一个images文件夹 名字.后缀的图片
}
}
]
},
{
test: /\.(eot|ttf|svg|woff|woff2)$/,
use: [
{
loader: 'file-loader',
options: {
name: 'fonts/[name][hash:8].[ext]'
}
}
}
]
}
]);
]
}
]
);

return storybookBaseConfig;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-react": "^7.7.0",
"eslint_d": "^5.3.0",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.9.0",
"html-loader": "^0.4.4",
"html-webpack-plugin": "^2.28.0",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ async@^1.4.0:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

async@^2.1.2, async@^2.1.4:
async@^2.1.2, async@^2.1.4, async@^2.4.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610"
dependencies:
Expand Down Expand Up @@ -4303,12 +4303,12 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"

extract-text-webpack-plugin@^2.0.0-beta.4:
version "2.1.2"
resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-2.1.2.tgz#756ef4efa8155c3681833fbc34da53b941746d6c"
extract-text-webpack-plugin@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-3.0.2.tgz#5f043eaa02f9750a9258b78c0a6e0dc1408fb2f7"
dependencies:
async "^2.1.2"
loader-utils "^1.0.2"
async "^2.4.1"
loader-utils "^1.1.0"
schema-utils "^0.3.0"
webpack-sources "^1.0.1"

Expand Down

0 comments on commit 9c67fbe

Please sign in to comment.