1
- var webpack = require ( 'webpack' )
2
- var config = require ( './webpack.base.conf' )
3
- var ExtractTextPlugin = require ( 'extract-text-webpack-plugin' ) ;
1
+ const webpack = require ( 'webpack' )
2
+ const config = require ( './webpack.base.conf' )
3
+ const ExtractTextPlugin = require ( 'extract-text-webpack-plugin' )
4
+ const UglifyJSPlugin = require ( 'uglifyjs-webpack-plugin' )
5
+ const path = require ( 'path' )
4
6
5
-
6
- // naming output files with hashes for better caching.
7
- // dist/index.html will be auto-generated with correct URLs.
8
7
config . output . filename = 'vue-image-lightbox.min.js'
9
- config . output . libraryTarget = 'commonjs2'
10
-
11
- // config.entry = './src/main.js'
12
- config . entry = './src/components/Lightbox.vue'
13
8
14
- // whether to generate source map for production files.
15
- // disabling this can speed up the build.
16
- var SOURCE_MAP = true
9
+ config . entry = path . resolve ( __dirname , '../src/components/Lightbox.vue' )
17
10
18
- config . devtool = SOURCE_MAP ? ' source-map' : false
11
+ config . devtool = '# source-map'
19
12
20
- config . vue = {
21
- loaders : {
22
- css : ExtractTextPlugin . extract ( "css" ) ,
23
- }
24
- } ,
13
+ config . module . rules . push ( {
14
+ test : / \. c s s $ / ,
15
+ use : ExtractTextPlugin . extract ( {
16
+ fallback : "style-loader" ,
17
+ use : "css-loader" ,
18
+ } ) ,
19
+ } )
25
20
26
21
config . plugins = ( config . plugins || [ ] ) . concat ( [
27
22
new webpack . DefinePlugin ( {
28
- 'process.env' : {
29
- NODE_ENV : '"production"'
30
- }
23
+ 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) ,
31
24
} ) ,
32
25
33
- new ExtractTextPlugin ( "vue-image-lightbox.min.css" ) ,
26
+ new ExtractTextPlugin ( {
27
+ filename : 'vue-image-lightbox.min.css' ,
28
+ } ) ,
34
29
35
- new webpack . optimize . UglifyJsPlugin ( {
30
+ new UglifyJSPlugin ( {
36
31
compress : {
37
- warnings : false
32
+ warnings : false ,
33
+ drop_debugger : true ,
34
+ drop_console : true ,
35
+ screw_ie8 : true ,
36
+ global_defs : {
37
+ 'process.env.NODE_ENV' : JSON . stringify ( process . env . NODE_ENV ) ,
38
+ } ,
39
+ } ,
40
+
41
+ mangle : {
42
+ screw_ie8 : true ,
43
+ } ,
44
+
45
+ output : {
46
+ comments : false ,
47
+ screw_ie8 : true ,
38
48
}
39
49
} ) ,
40
50
41
- new webpack . optimize . OccurenceOrderPlugin ( )
51
+ new webpack . optimize . OccurrenceOrderPlugin ( ) ,
42
52
] )
43
53
44
54
module . exports = config
0 commit comments