-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d0ca34
commit 9c67fbe
Showing
3 changed files
with
74 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters