1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const webpack = require("webpack");
|
10 | const paths = require("./paths");
|
11 | const path = require("path");
|
12 | const os = require("os");
|
13 | const ParallelUglifyPlugin = require("webpack-parallel-uglify-plugin");
|
14 |
|
15 | const publicPath = "/";
|
16 |
|
17 |
|
18 | const vendors = require(paths.appConfig).vendors || [];
|
19 |
|
20 |
|
21 | let entry = {};
|
22 | if (Array.isArray(vendors)) {
|
23 | entry = {
|
24 | vendors: vendors
|
25 | };
|
26 | }
|
27 | if (vendors.toString() === "[object Object]") {
|
28 | entry = vendors;
|
29 | }
|
30 |
|
31 | module.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 | };
|