UNPKG

1.51 kBJavaScriptView Raw
1/*
2 * @Author: Eward
3 * @Date: 2017-08-17 21:26:07
4 * @Last Modified by: Eward
5 * @Last Modified time: 2017-09-30 13:20:11
6 */
7
8 //不再使用
9const webpack = require("webpack");
10const paths = require("./paths");
11const path = require("path");
12const os = require("os");
13const ParallelUglifyPlugin = require("webpack-parallel-uglify-plugin");
14
15const publicPath = "/";
16
17// const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
18const vendors = require(paths.appConfig).vendors || [];
19
20/** ---- 如果vendor是object,则有可能是用户欲分别拆分包 ---- by Eward */
21let entry = {};
22if (Array.isArray(vendors)) {
23 entry = {
24 vendors: vendors
25 };
26}
27if (vendors.toString() === "[object Object]") {
28 entry = vendors;
29}
30
31module.exports = {
32 entry: entry,
33
34 output: {
35 filename: "static/js/[name].dll.js",
36 path: paths.appBuild,
37 library: "[name]_lib",
38 publicPath: publicPath
39 },
40 resolve: {
41 modules: ["node_modules", paths.appNodeModules]
42 },
43 plugins: [
44 new webpack.DllPlugin({
45 path: path.join(paths.appBuild, "[name]-dll-manifest.json"),
46 name: "[name]_lib"
47 }),
48 new webpack.DefinePlugin({
49 "process.env": {
50 NODE_ENV: JSON.stringify("production")
51 }
52 }),
53 new ParallelUglifyPlugin({
54 cacheDir: ".cache/",
55 uglifyJS: {
56 compress: {
57 warnings: false,
58 comparisons: false
59 },
60 output: {
61 comments: false,
62 ascii_only: true
63 }
64 }
65 })
66 ]
67};