2017-07-05 21:08:51 +08:00
|
|
|
|
var path = require('path');
|
2017-07-25 14:18:57 +08:00
|
|
|
|
var StringReplacePlugin = require("string-replace-webpack-plugin");
|
|
|
|
|
var ExtractTextPlugin = require("extract-text-webpack-plugin");
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
})
|
2017-07-05 19:31:50 +08:00
|
|
|
|
module.exports = {
|
2017-07-10 21:29:03 +08:00
|
|
|
|
plugins: [{
|
2017-07-11 10:22:06 +08:00
|
|
|
|
name: 'antd',
|
|
|
|
|
options: {
|
2017-07-25 14:18:57 +08:00
|
|
|
|
modifyQuery: function (defaultQuery) { // 可查看和编辑 defaultQuery
|
2017-07-11 10:22:06 +08:00
|
|
|
|
defaultQuery.plugins.push('transform-decorators-legacy');
|
|
|
|
|
return defaultQuery;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}],
|
2017-07-14 12:18:55 +08:00
|
|
|
|
// devtool: 'cheap-source-map',
|
2017-07-25 14:18:57 +08:00
|
|
|
|
config: function(ykit){
|
|
|
|
|
return {
|
2017-07-06 14:25:52 +08:00
|
|
|
|
exports: [
|
|
|
|
|
'./index.js'
|
|
|
|
|
],
|
2017-07-25 14:18:57 +08:00
|
|
|
|
modifyWebpackConfig: function (baseConfig) {
|
|
|
|
|
|
2017-07-14 14:44:32 +08:00
|
|
|
|
baseConfig.devtool = 'cheap-module-eval-source-map'
|
2017-07-06 14:25:52 +08:00
|
|
|
|
baseConfig.context = path.resolve(__dirname, "client");
|
2017-07-25 14:18:57 +08:00
|
|
|
|
|
|
|
|
|
baseConfig.output.prd.path = 'static/prd';
|
|
|
|
|
baseConfig.output.prd.publicPath = '';
|
|
|
|
|
baseConfig.output.prd.filename = '[name][ext]'
|
|
|
|
|
|
|
|
|
|
var stringReplace = {
|
|
|
|
|
test: "/static/index.html$",
|
|
|
|
|
loader: StringReplacePlugin.replace({
|
|
|
|
|
replacements: [
|
|
|
|
|
{
|
|
|
|
|
pattern: /@@VERSION_NUM/,
|
|
|
|
|
replacement: function () {
|
|
|
|
|
return 11111
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
baseConfig.module.loaders.push(stringReplace)
|
|
|
|
|
baseConfig.plugins.push(new StringReplacePlugin())
|
|
|
|
|
|
|
|
|
|
baseConfig.plugins.push(assetsPluginInstance)
|
|
|
|
|
|
|
|
|
|
baseConfig.module.loaders.push({
|
|
|
|
|
test: /\.(sass|scss)$/,
|
|
|
|
|
loader: ykit.ExtractTextPlugin.extract(
|
|
|
|
|
require.resolve('css-loader')
|
|
|
|
|
+ '?sourceMap!'
|
|
|
|
|
+ require.resolve('fast-sass-loader') + '?sourceMap'
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
2017-07-06 14:25:52 +08:00
|
|
|
|
return baseConfig;
|
|
|
|
|
}
|
2017-07-25 14:18:57 +08:00
|
|
|
|
}
|
2017-07-06 14:25:52 +08:00
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
// true/false,默认 false,效果相当于 ykit server --hot
|
2017-07-20 16:27:10 +08:00
|
|
|
|
hot: true
|
2017-07-06 14:25:52 +08:00
|
|
|
|
// true/false,默认 false,开启后可在当前打开的页面提示打包错误
|
2017-07-20 16:27:10 +08:00
|
|
|
|
// overlay: true
|
2017-07-06 14:25:52 +08:00
|
|
|
|
},
|
|
|
|
|
hooks: {},
|
|
|
|
|
commands: []
|
2017-07-05 19:31:50 +08:00
|
|
|
|
};
|