1- const UglifyJSPlugin = require ( 'uglifyjs-webpack-plugin' ) ;
2- const webpack = require ( 'webpack' ) ;
3- const Config = require ( 'webpack-chain' ) ;
1+ const UglifyJSPlugin = require ( 'uglifyjs-webpack-plugin' )
2+ const webpack = require ( 'webpack' )
3+ const Config = require ( 'webpack-chain' )
44module . exports = ( api , options ) => {
55 api . registerCommand (
66 'build:electron' ,
@@ -15,87 +15,87 @@ module.exports = (api, options) => {
1515 } ,
1616 async ( ) => {
1717 const buildRenderer = require ( '@vue/cli-service/lib/commands/build' )
18- . build ;
19- const fs = require ( 'fs-extra' ) ;
20- const builder = require ( 'electron-builder' ) ;
21- const rendererConfig = api . resolveChainableWebpackConfig ( ) ;
18+ . build
19+ const fs = require ( 'fs-extra' )
20+ const builder = require ( 'electron-builder' )
21+ const rendererConfig = api . resolveChainableWebpackConfig ( )
2222 const defaultBuildConfig = {
2323 directories : {
2424 output : 'dist_electron'
2525 } ,
2626 files : [ 'dist/**/*' , 'node_modules/**/*' , 'package.json' ] ,
2727 extends : null
28- } ;
29- const userBuildConfig = ( function ( ) {
28+ }
29+ const userBuildConfig = ( function ( ) {
3030 if (
3131 options . pluginOptions &&
3232 options . pluginOptions . electronBuilder &&
3333 options . pluginOptions . electronBuilder . builderConfig
3434 ) {
35- return options . pluginOptions . electronBuilder . builderConfig ;
35+ return options . pluginOptions . electronBuilder . builderConfig
3636 } else {
37- return { } ;
37+ return { }
3838 }
39- } ) ( ) ;
40- const mainConfig = new Config ( ) ;
39+ } ) ( )
40+ const mainConfig = new Config ( )
4141 mainConfig
4242 . mode ( 'production' )
4343 . devtool ( 'source-map' )
4444 . target ( 'electron-main' )
4545 . node . set ( '__dirname' , false )
46- . set ( '__filename' , false ) ;
47- mainConfig . output . path ( api . resolve ( './dist' ) ) . filename ( 'background.js' ) ;
46+ . set ( '__filename' , false )
47+ mainConfig . output . path ( api . resolve ( './dist' ) ) . filename ( 'background.js' )
4848 mainConfig . plugin ( 'uglify' ) . use ( UglifyJSPlugin , [
4949 {
5050 parallel : true ,
5151 sourceMap : true
5252 }
53- ] ) ;
53+ ] )
5454 mainConfig
5555 . plugin ( 'env' )
56- . use ( webpack . EnvironmentPlugin , [ { NODE_ENV : 'production' } ] ) ;
57- mainConfig . entry ( 'background' ) . add ( api . resolve ( './src/background.js' ) ) ;
56+ . use ( webpack . EnvironmentPlugin , [ { NODE_ENV : 'production' } ] )
57+ mainConfig . entry ( 'background' ) . add ( api . resolve ( './src/background.js' ) )
5858
59- console . log ( 'Bundling render process:' ) ;
60- rendererConfig . target ( 'electron-renderer' ) . output . publicPath ( './' ) ;
61- await buildRenderer ( { _ : [ ] } , api , options , rendererConfig ) ;
59+ console . log ( 'Bundling render process:' )
60+ rendererConfig . target ( 'electron-renderer' ) . output . publicPath ( './' )
61+ await buildRenderer ( { _ : [ ] } , api , options , rendererConfig )
6262 if ( fs . existsSync ( api . resolve ( './dist/fonts' ) ) ) {
63- fs . mkdirSync ( api . resolve ( './dist/css/fonts' ) ) ;
63+ fs . mkdirSync ( api . resolve ( './dist/css/fonts' ) )
6464 fs . copySync (
6565 api . resolve ( './dist/fonts' ) ,
6666 api . resolve ( './dist/css/fonts' )
67- ) ;
67+ )
6868 }
69- const bundle = webpack ( mainConfig . toConfig ( ) ) ;
70- console . log ( 'Bundling main process:\n' ) ;
69+ const bundle = webpack ( mainConfig . toConfig ( ) )
70+ console . log ( 'Bundling main process:\n' )
7171 bundle . run ( ( err , stats ) => {
7272 if ( err ) {
73- console . error ( err . stack || err ) ;
73+ console . error ( err . stack || err )
7474 if ( err . details ) {
75- console . error ( err . details ) ;
75+ console . error ( err . details )
7676 }
77- process . exit ( 1 ) ;
77+ process . exit ( 1 )
7878 }
7979
80- const info = stats . toJson ( ) ;
80+ const info = stats . toJson ( )
8181
8282 if ( stats . hasErrors ( ) ) {
83- console . error ( info . errors ) ;
84- process . exit ( 1 ) ;
83+ console . error ( info . errors )
84+ process . exit ( 1 )
8585 }
8686
8787 if ( stats . hasWarnings ( ) ) {
88- console . warn ( info . warnings ) ;
88+ console . warn ( info . warnings )
8989 }
9090
9191 console . log (
9292 stats . toString ( {
9393 chunks : false ,
9494 colors : true
9595 } )
96- ) ;
96+ )
9797
98- console . log ( '\nBuilding app with electron-builder:\n' ) ;
98+ console . log ( '\nBuilding app with electron-builder:\n' )
9999
100100 builder
101101 . build ( {
@@ -106,15 +106,15 @@ module.exports = (api, options) => {
106106 } )
107107 . then ( ( ) => {
108108 // handle result
109- console . log ( '\nBuild complete!\n' ) ;
109+ console . log ( '\nBuild complete!\n' )
110110 } )
111111 . catch ( err => {
112112 // handle error
113- throw err ;
114- } ) ;
115- } ) ;
113+ throw err
114+ } )
115+ } )
116116 }
117- ) ;
117+ )
118118 api . registerCommand (
119119 'serve:electron' ,
120120 {
@@ -123,61 +123,61 @@ module.exports = (api, options) => {
123123 details : `See https://github.com/nklayman/vue-cli-plugin-electron-builder for more details.`
124124 } ,
125125 ( ) => {
126- const execa = require ( 'execa' ) ;
127- const mainConfig = new Config ( ) ;
126+ const execa = require ( 'execa' )
127+ const mainConfig = new Config ( )
128128 mainConfig
129129 . mode ( 'development' )
130130 . devtool ( 'source-map' )
131131 . target ( 'electron-main' )
132132 . node . set ( '__dirname' , false )
133- . set ( '__filename' , false ) ;
133+ . set ( '__filename' , false )
134134 mainConfig . output
135135 . path ( api . resolve ( './dist_electron' ) )
136- . filename ( 'background.js' ) ;
136+ . filename ( 'background.js' )
137137 mainConfig . plugin ( 'uglify' ) . use ( UglifyJSPlugin , [
138138 {
139139 parallel : true ,
140140 sourceMap : true
141141 }
142- ] ) ;
142+ ] )
143143 mainConfig
144144 . plugin ( 'env' )
145- . use ( webpack . EnvironmentPlugin , [ { NODE_ENV : 'development' } ] ) ;
146- mainConfig . entry ( 'background' ) . add ( api . resolve ( './src/background.js' ) ) ;
147- const bundle = webpack ( mainConfig . toConfig ( ) ) ;
145+ . use ( webpack . EnvironmentPlugin , [ { NODE_ENV : 'development' } ] )
146+ mainConfig . entry ( 'background' ) . add ( api . resolve ( './src/background.js' ) )
147+ const bundle = webpack ( mainConfig . toConfig ( ) )
148148
149- console . log ( 'Bundling main process:\n' ) ;
149+ console . log ( 'Bundling main process:\n' )
150150 bundle . run ( ( err , stats ) => {
151151 if ( err ) {
152- console . error ( err . stack || err ) ;
152+ console . error ( err . stack || err )
153153 if ( err . details ) {
154- console . error ( err . details ) ;
154+ console . error ( err . details )
155155 }
156- process . exit ( 1 ) ;
156+ process . exit ( 1 )
157157 }
158158
159- const info = stats . toJson ( ) ;
159+ const info = stats . toJson ( )
160160
161161 if ( stats . hasErrors ( ) ) {
162- console . error ( info . errors ) ;
163- process . exit ( 1 ) ;
162+ console . error ( info . errors )
163+ process . exit ( 1 )
164164 }
165165
166166 if ( stats . hasWarnings ( ) ) {
167- console . warn ( info . warnings ) ;
167+ console . warn ( info . warnings )
168168 }
169169
170170 console . log (
171171 stats . toString ( {
172172 chunks : false ,
173173 colors : true
174174 } )
175- ) ;
175+ )
176176
177- console . log ( '\nStarting development server:\n' ) ;
177+ console . log ( '\nStarting development server:\n' )
178178
179179 api . service . run ( 'serve' ) . then ( server => {
180- console . log ( '\nLaunching Electron...\n' ) ;
180+ console . log ( '\nLaunching Electron...\n' )
181181 const child = execa (
182182 './node_modules/.bin/electron dist_electron/background.js' ,
183183 {
@@ -187,16 +187,16 @@ module.exports = (api, options) => {
187187 WEBPACK_DEV_SERVER_URL : server . url
188188 }
189189 }
190- ) ;
190+ )
191191 child . on ( 'exit' , ( ) => {
192- process . exit ( 0 ) ;
193- } ) ;
194- } ) ;
195- } ) ;
192+ process . exit ( 0 )
193+ } )
194+ } )
195+ } )
196196 }
197- ) ;
198- } ;
197+ )
198+ }
199199module . exports . defaultModes = {
200200 'build:electron' : 'production' ,
201201 'serve:electron' : 'development'
202- } ;
202+ }
0 commit comments