1 | const fs = require('fs');
|
2 | const path = require('path');
|
3 | const webpack = require('webpack');
|
4 | const merge = require('webpack-merge');
|
5 | const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
6 | var WebpackShellPlugin = require('webpack-shell-plugin');
|
7 | var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
|
8 | const OptimizeJsPlugin = require("optimize-js-plugin");
|
9 | const baseWebpackConfig = require('./base.conf');
|
10 | const utils = require('./utils')
|
11 |
|
12 | module.exports = function(params) {
|
13 | var configureType = params.configureType;
|
14 |
|
15 | var entry = utils.getEntryAliasList(params);
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | var mergeConf = merge(baseWebpackConfig(params), {
|
21 |
|
22 | entry: entry,
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | externals: {
|
28 | moment:{
|
29 | commonjs: "moment",
|
30 | amd: "moment",
|
31 | root: "moment",
|
32 | },
|
33 | fastclick:{
|
34 | commonjs: "fastclick",
|
35 | amd: "fastclick",
|
36 | root: "FastClick",
|
37 | },
|
38 | 'object-path':{
|
39 | commonjs: "object-path",
|
40 | amd: "object-path",
|
41 | root: "objectPath",
|
42 | },
|
43 | Vue: "Vue",
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | upaas:{
|
50 | commonjs: "upaas",
|
51 | amd: "upaas",
|
52 | root: "UPAAS",
|
53 | },
|
54 | },
|
55 | module: {
|
56 | rules: [
|
57 | {
|
58 | test: /\.js$/,
|
59 | use: [
|
60 | {
|
61 | loader: 'keep-loader',
|
62 | options:{
|
63 | keep:params.env.isBuildBeta ? "beta" : "official",
|
64 | }
|
65 | },
|
66 | {
|
67 | loader: 'babel-loader',
|
68 | options:{
|
69 | cacheDirectory:!params.env.isProduction,
|
70 | },
|
71 | }
|
72 | ],
|
73 | include: [params.source, path.resolve(params.root, './node_modules/@beisen/bsapp-fetch'), path.resolve(params.root, './node_modules/@beisen/bsapp-bssdk'), path.resolve(params.root, './node_modules/vue-echarts-v3/src')]
|
74 | },
|
75 | {
|
76 | test:/\.less$/,
|
77 | use: ExtractTextPlugin.extract({
|
78 | fallback: "style-loader",
|
79 | use: [{
|
80 | loader:'css-loader',
|
81 | },
|
82 | {
|
83 | loader:'postcss-loader',
|
84 | }, {
|
85 | loader:'less-loader',
|
86 | }],
|
87 | }),
|
88 | },{
|
89 | test:/\.css$/,
|
90 | use: ExtractTextPlugin.extract({
|
91 | fallback: 'style-loader',
|
92 | use: [{
|
93 | loader:'css-loader',
|
94 | }],
|
95 | }),
|
96 | }]
|
97 | },
|
98 | resolveLoader: {
|
99 | modules: [
|
100 | 'node_modules',
|
101 |
|
102 | ]
|
103 | },
|
104 | plugins: [
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | new ExtractTextPlugin({
|
114 | filename:'[name].css',
|
115 | allChunks: true,
|
116 | }),
|
117 | new WebpackShellPlugin({
|
118 | onBuildExit: ['node ./node_modules/@molejs/mole-tools/scripts/build-assets.js']
|
119 | }),
|
120 | ]
|
121 | }, params.extraConfig);
|
122 |
|
123 | return mergeConf;
|
124 | };
|