mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-09 05:16:23 +10:00
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { flattenPlugin } from '../../lib/plugin-api/util'
|
||||
|
||||
describe('flattenPlugin', () => {
|
||||
test('shoould hydrate plugin correctly', () => {
|
||||
test('should hydrate plugin correctly', () => {
|
||||
const plugin = { name: 'a', shortcut: 'a', module: { enhanceAppFiles: 'file' }}
|
||||
const hydratedPlugin = flattenPlugin(plugin, {}, {})
|
||||
expect(hydratedPlugin.name).toBe('a')
|
||||
@@ -10,7 +10,7 @@ describe('flattenPlugin', () => {
|
||||
expect(hydratedPlugin.enhanceAppFiles).toBe('file')
|
||||
})
|
||||
|
||||
test('shoould set \'enabled\' to false when \'pluginOptions\' is set to false.', () => {
|
||||
test('should set \'enabled\' to false when \'pluginOptions\' is set to false.', () => {
|
||||
const plugin = { name: 'a', shortcut: 'a', module: {}}
|
||||
const hydratedPlugin = flattenPlugin(plugin, false, {})
|
||||
expect(hydratedPlugin.name).toBe('a')
|
||||
@@ -18,7 +18,7 @@ describe('flattenPlugin', () => {
|
||||
expect(hydratedPlugin.enabled).toBe(false)
|
||||
})
|
||||
|
||||
test('shoould flatten functional plugin correctly.', () => {
|
||||
test('should flatten functional plugin correctly.', () => {
|
||||
const config = jest.fn(() => ({ enhanceAppFiles: 'file' }))
|
||||
const plugin = { name: 'a', shortcut: 'a', module: config }
|
||||
const pluginOptions = {}
|
||||
@@ -33,7 +33,7 @@ describe('flattenPlugin', () => {
|
||||
expect(Object.getPrototypeOf(config.mock.calls[0][1])).toBe(pluginContext)
|
||||
})
|
||||
|
||||
test('shoould flatten functional plugin correctly - options defaults to \'{}\'.', () => {
|
||||
test('should flatten functional plugin correctly - options defaults to \'{}\'.', () => {
|
||||
const config = jest.fn(() => ({ enhanceAppFiles: 'file' }))
|
||||
const plugin = { name: 'a', shortcut: 'a', module: config }
|
||||
const pluginOptions = undefined
|
||||
|
||||
@@ -18,7 +18,7 @@ async function prepareServer (sourceDir, cliOptions = {}, context) {
|
||||
const chokidar = require('chokidar')
|
||||
|
||||
const prepare = require('./prepare/index')
|
||||
const { chalk, logger } = require('@vuepress/shared-utils')
|
||||
const { chalk, fs, logger } = require('@vuepress/shared-utils')
|
||||
const HeadPlugin = require('./webpack/HeadPlugin')
|
||||
const DevLogPlugin = require('./webpack/DevLogPlugin')
|
||||
const createClientConfig = require('./webpack/createClientConfig')
|
||||
@@ -110,6 +110,8 @@ async function prepareServer (sourceDir, cliOptions = {}, context) {
|
||||
config = applyUserWebpackConfig(userConfig, config, false /* isServer */)
|
||||
}
|
||||
|
||||
const contentBase = path.resolve(sourceDir, '.vuepress/public')
|
||||
|
||||
const serverConfig = Object.assign({
|
||||
disableHostCheck: true,
|
||||
compress: true,
|
||||
@@ -124,14 +126,19 @@ async function prepareServer (sourceDir, cliOptions = {}, context) {
|
||||
ignored: /node_modules/
|
||||
},
|
||||
historyApiFallback: {
|
||||
disableDotRule: true,
|
||||
rewrites: [
|
||||
{ from: /\.html$/, to: '/' }
|
||||
{ from: /./, to: path.posix.join(ctx.base, 'index.html') }
|
||||
]
|
||||
},
|
||||
overlay: false,
|
||||
host,
|
||||
contentBase: path.resolve(sourceDir, '.vuepress/public'),
|
||||
contentBase,
|
||||
before (app, server) {
|
||||
if (fs.existsSync(contentBase)) {
|
||||
app.use(ctx.base, require('express').static(contentBase))
|
||||
}
|
||||
|
||||
ctx.pluginAPI.options.beforeDevServer.syncApply(app, server)
|
||||
},
|
||||
after (app, server) {
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = function createBaseConfig ({
|
||||
.output
|
||||
.path(outDir)
|
||||
.filename(isProd ? 'assets/js/[name].[chunkhash:8].js' : 'assets/js/[name].js')
|
||||
.publicPath(isProd ? publicPath : '/')
|
||||
.publicPath(publicPath)
|
||||
|
||||
if (env.isDebug) {
|
||||
config.devtool('source-map')
|
||||
|
||||
Reference in New Issue
Block a user