yapi/ykit.js
2017-07-27 21:38:30 +08:00

79 lines
2.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var path = require('path');
var AssetsPlugin = require('assets-webpack-plugin')
var assetsPluginInstance = new AssetsPlugin({
filename: 'static/prd/assets.js',
processOutput: function (assets) {
return 'window.WEBPACK_ASSETS = ' + JSON.stringify(assets);
}
})
module.exports = {
plugins: [{
name: 'antd',
options: {
modifyQuery: function (defaultQuery) { // 可查看和编辑 defaultQuery
defaultQuery.plugins.push('transform-decorators-legacy');
return defaultQuery;
}
}
}],
// devtool: 'cheap-source-map',
config: function (ykit) {
return {
exports: [
'./index.js'
],
commonsChunk: {
//filename: 'scripts/[name]@[chunkhash][ext]',
vendors: {
lib: ['react', 'redux',
'redux-thunk',
'react-dom',
'redux-promise',
'react-router-dom',
'prop-types',
'axios',
'moment'
],
lib2: [
'antd'
]
}
},
modifyWebpackConfig: function (baseConfig) {
baseConfig.devtool = 'cheap-module-eval-source-map'
baseConfig.context = path.resolve(__dirname, "client");
baseConfig.output.prd.path = 'static/prd';
baseConfig.output.prd.publicPath = '';
baseConfig.output.prd.filename = '[name]@[chunkhash][ext]'
baseConfig.module.loaders.push({
test: /\.(sass|scss)$/,
loader: ykit.ExtractTextPlugin.extract(
require.resolve('css-loader')
+ '?sourceMap!'
+ require.resolve('fast-sass-loader') + '?sourceMap'
)
})
baseConfig.module.preLoaders.push({
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: "eslint-loader"
});
if (this.env == 'prd') {
baseConfig.plugins.push(assetsPluginInstance)
}
return baseConfig;
}
}
},
server: {
// true/false默认 false效果相当于 ykit server --hot
hot: true
// true/false默认 false开启后可在当前打开的页面提示打包错误
// overlay: true
},
hooks: {},
commands: []
};