forked from PeachScript/vue-infinite-loading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
103 lines (100 loc) · 2.52 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
102
103
const path = require('path');
const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
'vue-infinite-loading': './src/index.js'
},
output: {
path: path.join(__dirname, '../dist'),
filename: '[name].js',
library: 'VueInfiniteLoading',
libraryTarget: 'umd',
globalObject: 'this'
},
resolve: {
extensions: ['.js', '.vue'],
alias: {
vue$: 'vue/dist/vue.min.js'
}
},
module: {
rules: [
{
test: /\.(vue|js)$/,
enforce: 'pre',
include: [path.join(__dirname, '../src'), path.join(__dirname, '../test')],
loader: 'eslint-loader',
options: {
formatter: require('eslint-formatter-friendly')
}
},
{
test: /\.js$/,
include: [path.join(__dirname, '../src'), path.join(__dirname, '../test')],
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-runtime'],
env: {
test: {
presets: [['@babel/preset-env', { useBuiltIns: 'usage', corejs: 2 }]],
plugins: ['babel-plugin-istanbul']
}
}
}
},
{
test: /\.vue$/,
use: [
path.join(__dirname, './ssr_vue_loader'),
'vue-loader'
]
},
{
test: /\.less$/,
use: [
'vue-style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 2
}
},
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: [
require('autoprefixer')
]
}
},
'less-loader'
]
}
]
},
plugins: [
new VueLoaderPlugin()
],
mode: process.env.NODE_ENV || 'development'
};
if (process.env.NODE_ENV === 'production') {
// production configurations
const pkg = require('../package');
const banner = [
`${pkg.name} v${process.env.VERSION || pkg.version}`,
`(c) 2016-${new Date().getFullYear()} ${pkg.author.name}`,
`${pkg.license} License`
].join('\n');
module.exports.plugins.push(new webpack.BannerPlugin(banner));
} else {
// development configurations
module.exports.plugins.push(new HtmlWebpackPlugin({
filename: 'index.html',
template: './scripts/dev_template.js',
inject: false
}));
}