const webpack = require('webpack'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const dirVars = require('./webpack/dir.config.js'); var path = require('path'); const version = require('./package.json').version; const argv = require('yargs').argv; let theme = { '@primary-color': '#58a3ff', '@link-color': '#58a3ff' }; module.exports = (function () { let staticHost = 'http://172.16.0.74'; switch (argv.env.deploy) { case 'test': staticHost = 'http://statics.jishutao.com'; break; case 'prod': staticHost = 'http://count.jishutao.com'; break; default: break; } staticHost = staticHost + '/client/' + version + '/'; theme['@icon-url'] = '"' + staticHost + 'css/iconfont/iconfont"' var dllContext = path.resolve(dirVars.dllDir, './' + argv.env.deploy); return { output: { path: dllContext, filename: '[name].js', library: '[name]', // 当前Dll的所有内容都会存放在这个参数指定变量名的一个全局变量下,注意与DllPlugin的name参数保持一致 }, entry: { dll: [ 'react', 'react-dom', 'antd', 'jquery/src/ajax/xhr.js', 'jquery/src/ajax', 'antd/lib/style' ], }, plugins: [ new webpack.DllPlugin({ path: path.resolve(dllContext, 'manifest.json'), name: '[name]', context: dirVars.staticRootDir, /* 当前Dll的所有内容都会存放在这个参数指定变量名的一个全局变量下,注意与参数output.library保持一致 指定一个路径作为上下文环境,需要与DllReferencePlugin的context参数保持一致,建议统一设置为项目根目录 这个配置文件的含义是指将enty中的dll[]中的内容 打包进react.dll.js这个文件中 */ }), new ExtractTextPlugin({ filename: "[name].css", disable: false, allChunks: true }), // 打包css/less的时候会用到ExtractTextPlugin new webpack.optimize.UglifyJsPlugin({ minimize: true, compress: { warnings: false, }, }), new webpack.DefinePlugin({ "process.env": { NODE_ENV: JSON.stringify("production") } }) ], module: require('./webpack/module.config.js')(theme), resolve: { extensions: ['.js', '.jsx'] } } })();