forked from phouri/vue-phone-input
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
115 lines (109 loc) · 2.3 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
104
105
106
107
108
109
110
111
112
113
114
115
'use strict';
const Webpack = require('webpack');
const Path = require('path');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const appPath = Path.resolve(__dirname, 'src');
const buildPath = Path.resolve(__dirname, 'lib');
const nodeModulesPath = Path.resolve(__dirname, 'node_modules');
const NODE_ENV = process.env.NODE_ENV || 'development';
const ASSET_PATH = process.env.ASSET_PATH || './';
const webpackConfig = {
context: appPath,
entry: '/',
module: {
rules: [
{
test: /\.(vue|js)$/,
enforce: 'pre',
loader: 'eslint',
},
{
test: /\.js$/,
loader: 'babel',
},
{
test: /\.vue$/,
loader: 'vue',
},
{
test: /\.css$/,
loader: 'css',
},
{
test: /\.less$/,
use: ExtractTextWebpackPlugin.extract({
use: [
'css',
'less',
],
}),
},
{
test: /\.(png|gif|svg|jpe?g)$/,
loader: 'file',
options: {
name: '[path][name].[ext]'
}
},
],
},
resolveLoader: {
moduleExtensions: [
'-loader',
],
},
resolve: {
extensions:[
'.js',
'.vue',
],
},
watch: true,
watchOptions: {
aggregateTimeout: 100,
},
devtool: 'eval',
plugins: [
new ExtractTextWebpackPlugin({
filename: 'styles.css',
disable: false,
allChunks: true,
}),
new Webpack.NoEmitOnErrorsPlugin(),
new Webpack.DefinePlugin({
NODE_ENV: JSON.stringify(NODE_ENV),
}),
],
externals: {},
output: {
path: buildPath,
publicPath: ASSET_PATH,
filename: 'index.js',
libraryTarget: 'umd',
library: 'VuePhoneInput',
},
};
if (NODE_ENV === 'production') {
webpackConfig.devtool = false;
webpackConfig.watch = false;
[
'vue',
].forEach((item) => {
webpackConfig.externals[item] = item;
});
webpackConfig.plugins.push(new Webpack.optimize.AggressiveMergingPlugin());
webpackConfig.plugins.push(new Webpack.optimize.UglifyJsPlugin({
beautify: false,
mangle: {
screw_ie8: true,
},
compress: {
warnings: false,
drop_console: true,
unsafe: true,
screw_ie8: true,
},
comments: false,
}));
}
module.exports = webpackConfig;