1 | 'use strict'
|
2 |
|
3 | const webpack = require('webpack')
|
4 | const config = require('../config')
|
5 | const { banner, isObject } = require('../libs/utils')
|
6 | const webpackBaseConf = require('./webpack.base.conf')()
|
7 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
8 | const maraConf = require(config.paths.marauder)
|
9 | const { babelLoader } = require('./loaders/babel-loader')
|
10 | const isProd = process.env.NODE_ENV === 'production'
|
11 | const library = '[name]_lib'
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const vendor = isObject(maraConf.vendor)
|
17 | ? maraConf.vendor.libs
|
18 | : maraConf.vendor
|
19 |
|
20 | const namespace = maraConf.vendor.name ? `${maraConf.vendor.name}_` : ''
|
21 |
|
22 | module.exports = function() {
|
23 | return {
|
24 | entry: {
|
25 | vendor
|
26 | },
|
27 |
|
28 | output: {
|
29 | filename: '[name].dll.js',
|
30 | path: `${config.paths.dist}/${namespace}vendor`,
|
31 | library
|
32 | },
|
33 |
|
34 | resolve: webpackBaseConf.resolve,
|
35 |
|
36 | module: {
|
37 | rules: [babelLoader(isProd)]
|
38 | },
|
39 |
|
40 | plugins: [
|
41 | new webpack.DefinePlugin(config.build.env.stringified),
|
42 | new webpack.DllPlugin({
|
43 | path: `${config.paths.dll}/${namespace}manifest.json`,
|
44 |
|
45 | name: library
|
46 | }),
|
47 | new UglifyJsPlugin({
|
48 | uglifyOptions: {
|
49 | ecma: 5,
|
50 | compress: {
|
51 | warnings: false,
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | comparisons: false
|
57 | },
|
58 | mangle: {
|
59 | safari10: true
|
60 | },
|
61 | output: {
|
62 | comments: false,
|
63 |
|
64 |
|
65 | ascii_only: true
|
66 | }
|
67 | },
|
68 |
|
69 |
|
70 | parallel: true,
|
71 |
|
72 | cache: true,
|
73 | sourceMap: false
|
74 | }),
|
75 |
|
76 | new webpack.BannerPlugin({
|
77 | banner: banner(),
|
78 | entryOnly: true
|
79 | })
|
80 | ]
|
81 | }
|
82 | }
|