Skip to content

Commit 0d5aa37

Browse files
authored
Merge pull request #1 from sumcumo/feat/updating_eslint
Updates
2 parents aae3c8d + 7c8dd74 commit 0d5aa37

File tree

8 files changed

+40
-31
lines changed

8 files changed

+40
-31
lines changed

generator/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const chalk = require('chalk')
66

77
module.exports = (api, options, rootOptions) => {
88
if (!api.hasPlugin('router')) {
9-
throw new Error(`Please install router plugin with 'vue add router'.`)
9+
throw new Error('Please install router plugin with \'vue add router\'.')
1010
}
1111

1212
api.extendPackage({
@@ -42,16 +42,16 @@ module.exports = (api, options, rootOptions) => {
4242
const file = getFile(api, './src/main.js')
4343
if (file) {
4444
let contents = fs.readFileSync(file, { encoding: 'utf8' })
45-
contents = contents.replace(/import router from ('|")\.\/router(\.\w+)?('|")/, `import { createRouter } from $1./router$3`)
46-
contents = contents.replace(/import store from ('|")\.\/store(\.\w+)?('|")/, `import { createStore } from $1./store$3`)
47-
contents = contents.replace(/import ('|")\.\/registerServiceWorker('|")\n/, ``)
48-
contents = contents.replace(/const apolloProvider = createProvider\(({(.|\s)*?})?\)\n/, ``)
45+
contents = contents.replace(/import router from ('|")\.\/router(\.\w+)?('|")/, 'import { createRouter } from $1./router$3')
46+
contents = contents.replace(/import store from ('|")\.\/store(\.\w+)?('|")/, 'import { createStore } from $1./store$3')
47+
contents = contents.replace(/import ('|")\.\/registerServiceWorker('|")\n/, '')
48+
contents = contents.replace(/const apolloProvider = createProvider\(({(.|\s)*?})?\)\n/, '')
4949
contents = contents.replace(/new Vue\({((.|\s)*)}\)\.\$mount\(.*?\)/, `export async function createApp ({
5050
beforeApp = () => {},
5151
afterApp = () => {}
5252
} = {}) {
5353
const router = createRouter()
54-
${templateOptions.vuex ? `const store = createStore()` : ''}
54+
${templateOptions.vuex ? 'const store = createStore()' : ''}
5555
${templateOptions.apollo ? `const apolloProvider = createProvider({
5656
ssr: process.server,
5757
})` : ''}
@@ -87,7 +87,7 @@ module.exports = (api, options, rootOptions) => {
8787
let contents = fs.readFileSync(file, { encoding: 'utf8' })
8888
contents = contents.replace(/export default new Router\({((.|\s)+)}\)/, `export function createRouter () {
8989
return new Router({
90-
${contents.includes('mode:') ? '' : `mode: 'history',`}$1})
90+
${contents.includes('mode:') ? '' : 'mode: \'history\','}$1})
9191
}`)
9292
contents = contents.replace(/mode:\s*("|')(hash|abstract)("|'),/, '')
9393
fs.writeFileSync(file, contents, { encoding: 'utf8' })
@@ -126,7 +126,7 @@ module.exports = (api, options, rootOptions) => {
126126
contents = contents.replace(/export default app => {((.|\s)*)}/, `export default app => {$1
127127
ssrMiddleware(app, { prodOnly: true })
128128
}`)
129-
contents = `import ssrMiddleware from '@akryum/vue-cli-plugin-ssr/lib/app'\n` + contents
129+
contents = 'import ssrMiddleware from \'@akryum/vue-cli-plugin-ssr/lib/app\'\n' + contents
130130
fs.writeFileSync(file, contents, { encoding: 'utf8' })
131131
}
132132

generator/templates/default/src/entry-client.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<%_ if (apollo) { _%>
2+
import 'isomorphic-fetch'
3+
<%_ } _%>
14
import { loadAsyncComponents } from '@akryum/vue-cli-plugin-ssr/client'
25
<%_ if (pwa) { _%>
36
import './registerServiceWorker'
@@ -14,13 +17,16 @@ createApp({
1417

1518
afterApp ({
1619
app,
20+
router,
1721
<%_ if (vuex) { _%>
1822
store,
1923
<%_ } _%>
2024
}) {
2125
<%_ if (vuex) { _%>
2226
store.replaceState(window.__INITIAL_STATE__)
2327
<%_ } _%>
24-
app.$mount('#app')
28+
router.onReady(() => {
29+
app.$mount('#app')
30+
})
2531
}
2632
})

lib/dev-server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const chalk = require('chalk')
55

66
const config = require('./config')
77

8-
module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Promise((resolve, reject) => {
8+
module.exports.setupDevServer = ({ server, templatePath, onUpdate, webpackConfig }) => new Promise((resolve, reject) => {
99
const service = config.service
1010
if (!service) {
1111
reject(new Error('No cli-service available. Make sure you ran the command with `vue-cli-service`.'))
@@ -20,7 +20,7 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
2020
}
2121

2222
const { getWebpackConfigs } = require('./webpack')
23-
const [clientConfig, serverConfig] = getWebpackConfigs(service)
23+
const [clientConfig, serverConfig] = getWebpackConfigs(service, webpackConfig)
2424

2525
let serverBundle
2626
let template
@@ -126,7 +126,7 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
126126

127127
setTimeout(() => {
128128
console.log()
129-
console.log(` App running at:`)
129+
console.log(' App running at:')
130130
console.log(` - Local: ${chalk.cyan(url)} ${copied}`)
131131
})
132132
}

lib/loaders/css-context.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ module.exports.pitch = function (remainingRequest) {
2727

2828
if (isServer && isProduction) {
2929
const shared = [
30-
`// load the styles`,
30+
'// load the styles',
3131
`var content = require(${request});`,
3232
// content list format is [id, css, media, sourceMap]
33-
`if(typeof content === 'string') content = [[module.id, content, '']];`,
34-
`module.exports = content;`,
35-
`if(content.locals) module.exports = content.locals;`,
33+
'if(typeof content === \'string\') content = [[module.id, content, \'\']];',
34+
'module.exports = content;',
35+
'if(content.locals) module.exports = content.locals;',
3636
]
3737
// on the server: attach to Vue SSR context
3838
if (isVue) {
3939
// inside *.vue file: expose a function so it can be called in
4040
// component's lifecycle hooks
4141
return shared.concat([
42-
`// add CSS to SSR context`,
42+
'// add CSS to SSR context',
4343
`var add = require(${addStylesServerPath}).default`,
44-
`module.exports.__inject__ = function (context) {`,
44+
'module.exports.__inject__ = function (context) {',
4545
` add(${id}, content, ${isProduction}, context)`,
46-
`};`,
46+
'};',
4747
]).join('\n')
4848
} else {
4949
// normal import

lib/server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exports.createServer = ({
55
port,
66
host,
77
}) => {
8+
/* eslint-disable-next-line no-async-promise-executor */
89
return new Promise(async (resolve, reject) => {
910
const app = express()
1011

lib/webpack.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,26 @@ exports.chainWebpack = (webpackConfig) => {
4343
// HTML
4444
webpackConfig.plugin('html-filter').use(HtmlFilterPlugin)
4545
if (isProd) {
46+
// TODO Make customizable from outside
4647
webpackConfig.plugin('html').tap(args => {
4748
args[0].minify.removeComments = false
49+
args[0].minify.caseSensitive = true
4850
return args
4951
})
5052
}
5153

5254
webpackConfig.entry('app').clear().add(config.entry(target))
5355

5456
webpackConfig.plugin('define').tap(args => {
55-
return [Object.assign(args[0], {'process.client': target === 'client', 'process.server': target === 'server'})]
57+
return [Object.assign(args[0], { 'process.client': target === 'client', 'process.server': target === 'server' })]
5658
})
5759

5860
webpackConfig.stats(isProd ? 'normal' : 'none')
5961
webpackConfig.devServer.stats('errors-only').quiet(true).noInfo(true)
6062

6163
if (isClient) {
6264
webpackConfig.plugin('ssr').use(VueSSRClientPlugin)
63-
webpackConfig.plugin('loader').use(WebpackBar, [{name: 'Client', color: 'green'}])
65+
webpackConfig.plugin('loader').use(WebpackBar, [{ name: 'Client', color: 'green' }])
6466

6567
webpackConfig.devtool(!isProd ? '#cheap-module-source-map' : undefined)
6668

@@ -70,10 +72,10 @@ exports.chainWebpack = (webpackConfig) => {
7072
})
7173
} else {
7274
webpackConfig.plugin('ssr').use(VueSSRServerPlugin)
73-
webpackConfig.plugin('loader').use(WebpackBar, [{name: 'Server', color: 'orange'}])
75+
webpackConfig.plugin('loader').use(WebpackBar, [{ name: 'Server', color: 'orange' }])
7476

7577
webpackConfig.devtool('source-map')
76-
webpackConfig.externals(nodeExternals({whitelist: config.nodeExternalsWhitelist}))
78+
webpackConfig.externals(nodeExternals({ whitelist: config.nodeExternalsWhitelist }))
7779
webpackConfig.output.libraryTarget('commonjs2'); webpackConfig.target('node')
7880
webpackConfig.optimization.splitChunks(false).minimize(false)
7981

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@
5050
"webpackbar": "^2.6.3"
5151
},
5252
"devDependencies": {
53-
"eslint": "^4.13.1",
54-
"eslint-config-standard": "^11.0.0",
53+
"eslint": "^6.2.1",
54+
"eslint-config-standard": "^14.0.1",
5555
"eslint-plugin-import": "^2.13.0",
56-
"eslint-plugin-node": "^7.0.1",
57-
"eslint-plugin-promise": "^3.8.0",
58-
"eslint-plugin-standard": "^3.1.0",
56+
"eslint-plugin-node": "^9.1.0",
57+
"eslint-plugin-promise": "^4.2.1",
58+
"eslint-plugin-standard": "^4.0.1",
5959
"vuepress": "^0.14.8"
6060
},
6161
"peerDependencies": {

ui.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ module.exports = api => {
1515

1616
api.describeTask({
1717
match: /vue-cli-service ssr:serve --mode production/,
18-
description: `Starts the included HTTP server for SSR in production`,
18+
description: 'Starts the included HTTP server for SSR in production',
1919
link: 'https://github.com/Akryum/vue-cli-plugin-ssr#usage',
2020
...taskCommon,
2121
})
2222

2323
api.describeTask({
2424
match: /vue-cli-service ssr:serve/,
25-
description: `Compiles and hot-reloads for development with SSR`,
25+
description: 'Compiles and hot-reloads for development with SSR',
2626
link: 'https://github.com/Akryum/vue-cli-plugin-ssr#usage',
2727
...taskCommon,
2828
})
2929

3030
api.describeTask({
3131
match: /vue-cli-service ssr:build/,
32-
description: `Compiles and minifies for production with SSR`,
32+
description: 'Compiles and minifies for production with SSR',
3333
link: 'https://github.com/Akryum/vue-cli-plugin-ssr#usage',
3434
})
3535
}

0 commit comments

Comments
 (0)