1 | var path = require('path')
|
2 | var webpack = require('webpack')
|
3 |
|
4 | module.exports = {
|
5 | entry: './src/index.js',
|
6 |
|
7 | output: {
|
8 | path: path.resolve(__dirname, './dist'),
|
9 | publicPath: '/dist/',
|
10 | library: 'vueShapeImg',
|
11 | libraryTarget: 'umd',
|
12 | umdNamedDefine: true,
|
13 | filename: 'vue-shape-img.js'
|
14 | },
|
15 | module: {
|
16 | rules: [
|
17 | {
|
18 | test: /\.css$/,
|
19 | use: [
|
20 | 'vue-style-loader',
|
21 | 'css-loader'
|
22 | ],
|
23 | }, {
|
24 | test: /\.vue$/,
|
25 | loader: 'vue-loader',
|
26 | options: {
|
27 | loaders: {
|
28 | }
|
29 |
|
30 | }
|
31 | },
|
32 | {
|
33 | test: /\.js$/,
|
34 | loader: 'babel-loader',
|
35 | exclude: /node_modules/
|
36 | },
|
37 | {
|
38 | test: /\.(png|jpg|gif|svg)$/,
|
39 | loader: 'file-loader',
|
40 | options: {
|
41 | name: '[name].[ext]?[hash]'
|
42 | }
|
43 | }
|
44 | ]
|
45 | },
|
46 | resolve: {
|
47 | alias: {
|
48 | 'vue$': 'vue/dist/vue.esm.js'
|
49 | },
|
50 | extensions: ['*', '.js', '.vue', '.json']
|
51 | },
|
52 | devServer: {
|
53 | historyApiFallback: true,
|
54 | noInfo: true,
|
55 | overlay: true,
|
56 | clientLogLevel: 'warning',
|
57 | hot: true,
|
58 | inline: false
|
59 | },
|
60 | performance: {
|
61 | hints: false
|
62 | },
|
63 | }
|
64 |
|
65 | if (process.env.NODE_ENV === 'production') {
|
66 |
|
67 | module.exports.plugins = (module.exports.plugins || []).concat([
|
68 | new webpack.DefinePlugin({
|
69 | 'process.env': {
|
70 | NODE_ENV: '"production"'
|
71 | }
|
72 | }),
|
73 | new webpack.optimize.UglifyJsPlugin({
|
74 | sourceMap: true,
|
75 | compress: {
|
76 | warnings: false
|
77 | }
|
78 | }),
|
79 | new webpack.LoaderOptionsPlugin({
|
80 | minimize: true
|
81 | })
|
82 | ])
|
83 | }
|