-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
101 lines (92 loc) · 2.63 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Created by loutao on 2016/12/10.
*/
var webpack = require('webpack');
var path = require('path');
var ManifestPlugin = require('webpack-manifest-plugin');
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
var WebpackMd5Hash = require('webpack-md5-hash');
function ConsolePlugin() {
}
ConsolePlugin.prototype.apply = function (compiler) {
compiler.plugin('run', function (compiler, callback) {
console.log('start');
callback();
});
};
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var configOne = {
// target: 'node',
entry: {
vendor: ['moment', 'babel-polyfill', 'lodash'],
main: './app/index.js',
// one: './app/another/app.js'
},
output: {
chunkFilename: '[id].js', // id和name一样
filename: '[name].bundle.js',
path: './dist',
// pathinfo: true,
// sourcePrefix: '\t',
// jsonpFunction: function () {
// console.log(1)
// },
// library: 'foo',
// libraryTarget: 'amd',
},
// externals: {
// "demond": {
// commonjs: "demond",
// root: 'demo'
// }
// },
resolve: {
// mainFiles: ['app'],
// extension: ['', 'js'],
// alias: {
// "vendor": path.resolve(__dirname, 'vendor/index')
// }
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
// {
// test: /\.css$/,
// exclude: /node_modules/,
// loader: ExtractTextPlugin.extract({
// loader: 'css-loader'
// }),
// loader: 'style-loader!css-loader'
// }
]
},
plugins: [
new ConsolePlugin(),
// new ExtractTextPlugin({filename: 'bundle.css'}),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest'],
// minChunks: Infinity
}),
// 按文件命名可以解决venfor file long term cache
// 也可以使用dllPlugin
new webpack.NamedModulesPlugin()
// new WebpackMd5Hash(),
// new ManifestPlugin(),
// new ChunkManifestPlugin({
// filename: 'chunk-manifest-json',
// manifestVariable: 'webpackManifest'
// })
// new webpack.ProvidePlugin({
// $: 'jquery'
// })
],
// recordsPath: path.resolve('./records.json')
// devtool: 'cheap-module-source-map'
};
var configTwo = {
};
module.exports = [configOne];