1 | const webpack = require('webpack');
|
2 | const path = require('path');
|
3 |
|
4 | const vendors = [];
|
5 |
|
6 | const options = {
|
7 | output: {
|
8 | path: path.join(__dirname, 'src/lib'),
|
9 | filename: 'vendors.js',
|
10 | library: 'vendors',
|
11 | },
|
12 | entry: {
|
13 | vendor: vendors,
|
14 | },
|
15 | plugins: [
|
16 | new webpack.DllPlugin({
|
17 | path: 'manifest.json',
|
18 | name: 'vendors',
|
19 | context: __dirname,
|
20 | }),
|
21 | new webpack.optimize.UglifyJsPlugin()
|
22 | ],
|
23 | }
|
24 |
|
25 |
|
26 | webpack(options, function (err, stats) {
|
27 |
|
28 | if (err) throw err
|
29 | process.stdout.write(stats.toString({
|
30 |
|
31 | colors: true,
|
32 | cached: false,
|
33 | modules: true,
|
34 | children: false,
|
35 | chunks: false,
|
36 | chunkModules: false
|
37 | }) + '\n\n')
|
38 |
|
39 | if (stats.hasErrors()) {
|
40 | console.log(' Build failed with errors.\n')
|
41 | process.exit(1)
|
42 | }
|
43 |
|
44 | console.log(' Build complete.\n')
|
45 | console.log(
|
46 | ' Tip: built files are meant to be served over an HTTP server.\n' +
|
47 | ' Opening index.html over file:// won\'t work.\n'
|
48 | );
|
49 | });
|