mirror of
https://github.com/YMFE/yapi.git
synced 2025-04-18 15:20:25 +08:00
chore: 修改ykit 构建
This commit is contained in:
parent
43d2ab3620
commit
46c0034230
87
ykit.js
87
ykit.js
@ -36,69 +36,6 @@ function initPlugins(){
|
||||
initPlugins();
|
||||
|
||||
|
||||
function handleCommonsChunk(webpackConfig) {
|
||||
var commonsChunk = {
|
||||
vendors: {
|
||||
lib: ['react', 'redux',
|
||||
'redux-thunk',
|
||||
'react-dom',
|
||||
'redux-promise',
|
||||
'react-router',
|
||||
'react-router-dom',
|
||||
'prop-types',
|
||||
'axios',
|
||||
'moment'
|
||||
|
||||
],
|
||||
lib2: [
|
||||
'brace',
|
||||
'mockjs',
|
||||
'json5'
|
||||
]
|
||||
}
|
||||
},
|
||||
chunks = [],
|
||||
filenameTpl = webpackConfig.output[this.env],
|
||||
vendors;
|
||||
|
||||
|
||||
|
||||
if (typeof commonsChunk === 'object' && commonsChunk !== undefined) {
|
||||
if (typeof commonsChunk.name === 'string' && commonsChunk) {
|
||||
chunks.push(commonsChunk.name);
|
||||
}
|
||||
vendors = commonsChunk.vendors;
|
||||
if (typeof vendors === 'object' && vendors !== undefined) {
|
||||
var i = 0;
|
||||
for (var name in vendors) {
|
||||
if (vendors.hasOwnProperty(name) && vendors[name]) {
|
||||
i++;
|
||||
chunks.push(name);
|
||||
webpackConfig.entry[name] = Array.isArray(vendors[name]) ? vendors[name] : [vendors[name]];
|
||||
}
|
||||
}
|
||||
if (i > 0) {
|
||||
chunks.push('manifest');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (chunks.length > 0) {
|
||||
let chunkFilename = filenameTpl.filename
|
||||
chunkFilename = chunkFilename.replace("[ext]", '.js')
|
||||
webpackConfig.plugins.push(
|
||||
new this.webpack.optimize.CommonsChunkPlugin({
|
||||
name: chunks,
|
||||
filename: chunkFilename,
|
||||
minChunks: commonsChunk.minChunks ? commonsChunk.minChunks : 2
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
plugins: [{
|
||||
name: 'antd',
|
||||
@ -122,6 +59,26 @@ module.exports = {
|
||||
exports: [
|
||||
'./index.js'
|
||||
],
|
||||
commonsChunk: {
|
||||
vendors: {
|
||||
lib: ['react', 'redux',
|
||||
'redux-thunk',
|
||||
'react-dom',
|
||||
'redux-promise',
|
||||
'react-router',
|
||||
'react-router-dom',
|
||||
'prop-types',
|
||||
'axios',
|
||||
'moment'
|
||||
|
||||
],
|
||||
lib2: [
|
||||
'brace',
|
||||
'mockjs',
|
||||
'json5'
|
||||
]
|
||||
}
|
||||
},
|
||||
modifyWebpackConfig: function (baseConfig) {
|
||||
|
||||
var ENV_PARAMS = {};
|
||||
@ -152,8 +109,8 @@ module.exports = {
|
||||
baseConfig.output.prd.publicPath = '';
|
||||
baseConfig.output.prd.filename = '[name]@[chunkhash][ext]'
|
||||
|
||||
//commonsChunk
|
||||
handleCommonsChunk.call(this, baseConfig)
|
||||
|
||||
|
||||
baseConfig.module.loaders.push({
|
||||
test: /\.less$/,
|
||||
loader: ykit.ExtractTextPlugin.extract(
|
||||
|
Loading…
x
Reference in New Issue
Block a user