123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- var path = require('path')
- var utils = require('./utils')
- var webpack = require('webpack')
- var config = require('../config')
- var merge = require('webpack-merge')
- var baseWebpackConfig = require('./webpack.base.conf')
- var UglifyJsPlugin = require('uglifyjs-webpack-plugin')
- var CopyWebpackPlugin = require('copy-webpack-plugin')
- var ExtractTextPlugin = require('extract-text-webpack-plugin')
- var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
- var MpvueVendorPlugin = require('webpack-mpvue-vendor-plugin')
- var env = config.build.env
- var webpackConfig = merge(baseWebpackConfig, {
- module: {
- rules: utils.styleLoaders({
- sourceMap: config.build.productionSourceMap,
- extract: true
- })
- },
- devtool: config.build.productionSourceMap ? '#source-map' : false,
- output: {
- path: config.build.assetsRoot,
-
-
- filename: utils.assetsPath('[name].js'),
- chunkFilename: utils.assetsPath('[id].js')
- },
- plugins: [
-
- new webpack.DefinePlugin({
- 'process.env': env
- }),
-
- new ExtractTextPlugin({
-
- filename: utils.assetsPath(`[name].${config.build.fileExt.style}`)
- }),
-
-
- new OptimizeCSSPlugin({
- cssProcessorOptions: {
- safe: true
- }
- }),
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- new webpack.HashedModuleIdsPlugin(),
-
- new webpack.optimize.CommonsChunkPlugin({
- name: 'common/vendor',
- minChunks: function (module, count) {
-
- return (
- module.resource &&
- /\.js$/.test(module.resource) &&
- module.resource.indexOf('node_modules') >= 0
- ) || count > 1
- }
- }),
-
-
- new webpack.optimize.CommonsChunkPlugin({
- name: 'common/manifest',
- chunks: ['common/vendor']
- }),
- new MpvueVendorPlugin({
- platform: process.env.PLATFORM
- })
- ]
- })
- if (config.build.bundleAnalyzerReport) {
- var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
- webpackConfig.plugins.push(new BundleAnalyzerPlugin())
- }
- var useUglifyJs = process.env.PLATFORM !== 'swan'
- if (useUglifyJs) {
- webpackConfig.plugins.push(new UglifyJsPlugin({
- sourceMap: true
- }))
- }
- module.exports = webpackConfig
|