forked from lincenying/mmf-blog-vue2-jsx-lc
/
cooking.conf.js
93 lines (86 loc) · 2.75 KB
/
cooking.conf.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
/* eslint-disable */
var path = require('path')
var cooking = require('cooking')
var webpack = require('webpack')
var CopyWebpackPlugin = require('copy-webpack-plugin')
var config = {
entry: {
app: './src/main.js',
login: './src/login.js',
vendor: ['vue', 'vue-router', 'vuex', 'vuex-router-sync', 'store2', 'toastr', './src/polyfill']
},
dist: './dist/static',
externals: {
'jquery': 'jQuery'
},
devServer: {
port: 8080,
publicPath: '/',
proxy: {
'/api/**': {
target: 'http://localhost:3000/',
secure: false,
changeOrigin: true
}
}
},
// production
clean: true,
hash: true,
sourceMap: false,
publicPath: '/static/',
assetsPath: 'images',
urlLoaderLimit: 10000,
extractCSS: 'css/[name].[contenthash:7].css',
extends: ['vue2', 'eslint']
}
if (process.env.NODE_ENV === 'production') {
config.template = [{
filename: '../index.html',
template: 'src/template/index.html',
chunks: ['manifest', 'vendor', 'app']
}, {
filename: '../login.html',
template: 'src/template/login.html',
chunks: ['manifest', 'vendor', 'login']
}]
} else {
config.template = [{
filename: 'index.html',
template: 'src/template/index.html',
chunks: ['vendor', 'app']
}, {
filename: 'login.html',
template: 'src/template/login.html',
chunks: ['vendor', 'login']
}]
}
cooking.set(config);
cooking.add('resolve.extensions', ['.js', '.vue', '.jsx'])
cooking.add('resolve.alias', {
'src': path.join(__dirname, 'src')
});
cooking.add('plugin.ProvidePlugin', new webpack.ProvidePlugin({$: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery'}))
if (process.env.NODE_ENV === 'production') {
cooking.add('output.filename', 'js/[name].[chunkhash:7].js')
cooking.add('output.chunkFilename', 'js/[id].[chunkhash:7].js')
cooking.add('plugin.CommonsChunk1', new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: function(module, count) {
return (module.resource && /\.js$/.test(module.resource) && module.resource.indexOf('node_modules') > 0)
}
}))
cooking.add('plugin.CommonsChunk2', new webpack.optimize.CommonsChunkPlugin({name: 'manifest', chunks: ['vendor']}))
cooking.add('plugin.CopyWebpackPlugin', new CopyWebpackPlugin([{
from: 'favicon.ico',
to: path.join(__dirname, 'dist')
}, {
from: 'static/editor.md/**/*',
to: path.join(__dirname, 'dist')
}]))
} else {
cooking.add('plugin.CommonsChunk', new webpack.optimize.CommonsChunkPlugin({
names: ["vendor"]
}))
}
module.exports = cooking.resolve()