/
webpack.config.js
86 lines (71 loc) · 1.87 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
const webpack = require('webpack')
const path = require('path')
const version = require('./package.json').version
const MinifyPlugin = require('babel-minify-webpack-plugin')
const merge = require('webpack-merge')
const banner = '/**\n' + ' * Acacha adminlte-vue ' + version + '\n' + ' * https://github.com/acacha/adminlte-vue\n' + ' * Released under the MIT License.\n' + ' */\n'
const isProd = (process.env.NODE_ENV === 'production')
let outputFile = 'acacha-adminlte-vue.js'
let outputFileNode = 'acacha-adminlte-vue.node.js'
if (isProd) {
outputFile = 'acacha-adminlte-vue.min.js'
outputFileNode = 'acacha-adminlte-vue.node.min.js'
}
function getPlugins () {
const plugins = []
plugins.push(new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
}))
plugins.push(new webpack.BannerPlugin({banner: banner, raw: true}))
// Conditionally add plugins for Production builds.
if (isProd) {
plugins.push(new MinifyPlugin())
}
return plugins
}
const shared = merge([
{
entry: './src/index.js',
plugins: getPlugins(),
module: {
rules: [{
enforce: 'pre',
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader'
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.vue?$/,
exclude: /node_modules/,
loader: 'vue-loader'
}
]
}
}
])
const umdOnly = {
output: {
path: path.resolve(__dirname, './dist'),
filename: outputFile,
libraryTarget: 'umd',
library: 'AcachaAdminlteVue',
umdNamedDefine: true
}
}
const umd = merge(shared, umdOnly)
const nodeOnly = {
target: 'node',
output: {
path: path.resolve(__dirname, './dist'),
filename: outputFileNode
}
}
const node = merge(shared, nodeOnly)
module.exports = [umd, node]