mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
merge with dev
This commit is contained in:
commit
32aeeab0ae
@ -1,3 +1,9 @@
|
||||
module.exports = {
|
||||
build: {
|
||||
postcss: [
|
||||
require('tailwindcss')('./tailwind.js'),
|
||||
require('autoprefixer')
|
||||
]
|
||||
},
|
||||
css: ['~/assets/css/tailwind.css']
|
||||
}
|
||||
|
@ -668,11 +668,15 @@ module.exports = class Builder {
|
||||
.on('unlink', refreshFiles)
|
||||
|
||||
// Watch for custom provided files
|
||||
const watchFiles = _.map(_.uniq(this.options.build.watch), p =>
|
||||
let customPatterns = _.concat(
|
||||
this.options.build.watch || [],
|
||||
_.values(_.omit(this.options.build.styleResources, 'options'))
|
||||
)
|
||||
customPatterns = _.map(_.uniq(customPatterns), p =>
|
||||
upath.normalizeSafe(p)
|
||||
)
|
||||
this.customFilesWatcher = chokidar
|
||||
.watch(watchFiles, options)
|
||||
.watch(customPatterns, options)
|
||||
.on('change', refreshFiles)
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,13 @@ module.exports = class ModuleContainer {
|
||||
})
|
||||
}
|
||||
|
||||
addLayout(template, name) {
|
||||
const { dst, src } = this.addTemplate(template)
|
||||
|
||||
// Add to nuxt layouts
|
||||
this.options.layouts[name || path.parse(src).name] = `./${dst}`
|
||||
}
|
||||
|
||||
addServerMiddleware(middleware) {
|
||||
this.options.serverMiddleware.push(middleware)
|
||||
}
|
||||
|
22
package.json
22
package.json
@ -61,13 +61,13 @@
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-loader": "^7.1.2",
|
||||
"babel-preset-vue-app": "^2.0.0",
|
||||
"caniuse-lite": "^1.0.30000792",
|
||||
"chalk": "^2.3.0",
|
||||
"chokidar": "^2.0.0",
|
||||
"caniuse-lite": "^1.0.30000808",
|
||||
"chalk": "^2.3.1",
|
||||
"chokidar": "^2.0.1",
|
||||
"clone": "^2.1.1",
|
||||
"compression": "^1.7.1",
|
||||
"connect": "^3.6.5",
|
||||
"css-hot-loader": "^1.3.6",
|
||||
"css-hot-loader": "^1.3.7",
|
||||
"css-loader": "^0.28.9",
|
||||
"debug": "^3.1.0",
|
||||
"es6-promise": "^4.2.4",
|
||||
@ -90,7 +90,7 @@
|
||||
"opencollective": "^1.0.3",
|
||||
"postcss": "^6.0.17",
|
||||
"postcss-cssnext": "^3.1.0",
|
||||
"postcss-import": "^11.0.0",
|
||||
"postcss-import": "^11.1.0",
|
||||
"postcss-import-resolver": "^1.1.0",
|
||||
"postcss-loader": "^2.1.0",
|
||||
"postcss-url": "^7.3.0",
|
||||
@ -98,7 +98,7 @@
|
||||
"progress-bar-webpack-plugin": "^1.10.0",
|
||||
"semver": "^5.5.0",
|
||||
"serialize-javascript": "^1.4.0",
|
||||
"serve-static": "^1.13.1",
|
||||
"serve-static": "^1.13.2",
|
||||
"server-destroy": "^1.0.1",
|
||||
"source-map": "^0.7.0",
|
||||
"style-resources-loader": "^1.0.0",
|
||||
@ -107,14 +107,14 @@
|
||||
"url-loader": "^0.6.2",
|
||||
"vue": "^2.5.13",
|
||||
"vue-loader": "^14.1.1",
|
||||
"vue-meta": "^1.4.2",
|
||||
"vue-meta": "^1.4.3",
|
||||
"vue-router": "^3.0.1",
|
||||
"vue-server-renderer": "^2.5.13",
|
||||
"vue-template-compiler": "^2.5.13",
|
||||
"vuex": "^3.0.1",
|
||||
"webpack": "^4.0.0",
|
||||
"webpack-bundle-analyzer": "^2.10.0",
|
||||
"webpack-dev-middleware": "^2.0.4",
|
||||
"webpack-dev-middleware": "^2.0.5",
|
||||
"webpack-hot-middleware": "^2.21.0",
|
||||
"webpack-node-externals": "^1.6.0"
|
||||
},
|
||||
@ -125,7 +125,7 @@
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-plugin-istanbul": "^4.1.5",
|
||||
"codecov": "^3.0.0",
|
||||
"copy-webpack-plugin": "^4.3.1",
|
||||
"copy-webpack-plugin": "^4.4.1",
|
||||
"cross-env": "^5.1.3",
|
||||
"eslint": "^4.17.0",
|
||||
"eslint-config-standard": "^11.0.0-beta.0",
|
||||
@ -144,8 +144,8 @@
|
||||
"puppeteer": "^1.0.0",
|
||||
"request": "^2.83.0",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"sinon": "^4.2.2",
|
||||
"uglify-js": "^3.3.9"
|
||||
"sinon": "^4.3.0",
|
||||
"uglify-js": "^3.3.10"
|
||||
},
|
||||
"collective": {
|
||||
"type": "opencollective",
|
||||
|
@ -11,7 +11,7 @@ const url = route => 'http://localhost:' + port + route
|
||||
const startCSPTestServer = async (t, csp) => {
|
||||
const options = {
|
||||
rootDir: resolve(__dirname, 'fixtures/basic'),
|
||||
buildDir: '.nuxt-ssr',
|
||||
buildDir: '.nuxt-ssr-csp',
|
||||
dev: false,
|
||||
head: {
|
||||
titleTemplate(titleChunk) {
|
||||
|
3
test/fixtures/module/modules/basic/index.js
vendored
3
test/fixtures/module/modules/basic/index.js
vendored
@ -8,6 +8,9 @@ module.exports = function basicModule(options, resolve) {
|
||||
// Add a plugin
|
||||
this.addPlugin(path.resolve(__dirname, 'reverse.js'))
|
||||
|
||||
// Add a layout
|
||||
this.addLayout(path.resolve(__dirname, 'layout.vue'))
|
||||
|
||||
// Extend build
|
||||
this.extendBuild((config, { isClient, isServer }) => {
|
||||
// Do nothing!
|
||||
|
6
test/fixtures/module/modules/basic/layout.vue
vendored
Normal file
6
test/fixtures/module/modules/basic/layout.vue
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>Module Layouts</h1>
|
||||
<nuxt />
|
||||
</div>
|
||||
</template>
|
6
test/fixtures/module/router.js
vendored
6
test/fixtures/module/router.js
vendored
@ -5,6 +5,7 @@ Vue.use(Router)
|
||||
|
||||
const indexPage = () => import('~/views/index.vue').then(m => m.default || m)
|
||||
const aboutPage = () => import('~/views/about.vue').then(m => m.default || m)
|
||||
const layoutPage = () => import('~/views/layout.vue').then(m => m.default || m)
|
||||
|
||||
export function createRouter() {
|
||||
return new Router({
|
||||
@ -19,6 +20,11 @@ export function createRouter() {
|
||||
path: '/about',
|
||||
component: aboutPage,
|
||||
name: 'about'
|
||||
},
|
||||
{
|
||||
path: '/layout',
|
||||
component: layoutPage,
|
||||
name: 'layout'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
10
test/fixtures/module/views/layout.vue
vendored
Normal file
10
test/fixtures/module/views/layout.vue
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<template>
|
||||
<div>
|
||||
Layout on module
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
layout: 'layout'
|
||||
}
|
||||
</script>
|
3
test/fixtures/with-config/nuxt.config.js
vendored
3
test/fixtures/with-config/nuxt.config.js
vendored
@ -46,7 +46,8 @@ module.exports = {
|
||||
maxChunkSize: 300000,
|
||||
analyze: {
|
||||
analyzerMode: 'disabled',
|
||||
generateStatsFile: true
|
||||
generateStatsFile: true,
|
||||
logLevel: 'error'
|
||||
},
|
||||
styleResources: {
|
||||
scss: '~/assets/pre-process.scss'
|
||||
|
@ -47,6 +47,16 @@ test.serial('Plugin', async t => {
|
||||
t.true(html.includes('<h1>TXUN</h1>'), 'plugin works')
|
||||
})
|
||||
|
||||
test.serial('Layout', async t => {
|
||||
t.true(
|
||||
nuxt.options.layouts.layout.includes('layout'),
|
||||
'layout added to config'
|
||||
)
|
||||
|
||||
const { html } = await nuxt.renderRoute('/layout')
|
||||
t.true(html.includes('<h1>Module Layouts</h1>'), 'layout works')
|
||||
})
|
||||
|
||||
test.serial('Hooks', async t => {
|
||||
t.is(nuxt.__module_hook, 1)
|
||||
t.is(nuxt.__renderer_hook, 2)
|
||||
|
18
yarn.lock
18
yarn.lock
@ -1618,7 +1618,7 @@ chokidar@^1.4.2, chokidar@^1.7.0:
|
||||
optionalDependencies:
|
||||
fsevents "^1.0.0"
|
||||
|
||||
chokidar@^2.0.0:
|
||||
chokidar@^2.0.1:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.0.2.tgz#4dc65139eeb2714977735b6a35d06e97b494dfd7"
|
||||
dependencies:
|
||||
@ -1994,7 +1994,7 @@ copy-descriptor@^0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
|
||||
|
||||
copy-webpack-plugin@^4.3.1:
|
||||
copy-webpack-plugin@^4.4.1:
|
||||
version "4.4.2"
|
||||
resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-4.4.2.tgz#c92bcd7df4d5e42c51398cc36b23820d0d10446a"
|
||||
dependencies:
|
||||
@ -2138,7 +2138,7 @@ css-color-names@0.0.4:
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0"
|
||||
|
||||
css-hot-loader@^1.3.6:
|
||||
css-hot-loader@^1.3.7:
|
||||
version "1.3.7"
|
||||
resolved "https://registry.yarnpkg.com/css-hot-loader/-/css-hot-loader-1.3.7.tgz#e08a2343d3f5e22043da50d86bbb4310f535be0e"
|
||||
dependencies:
|
||||
@ -5769,7 +5769,7 @@ postcss-import-resolver@^1.1.0:
|
||||
dependencies:
|
||||
enhanced-resolve "^3.4.1"
|
||||
|
||||
postcss-import@^11.0.0:
|
||||
postcss-import@^11.1.0:
|
||||
version "11.1.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-11.1.0.tgz#55c9362c9192994ec68865d224419df1db2981f0"
|
||||
dependencies:
|
||||
@ -6762,7 +6762,7 @@ serve-static@1.13.1:
|
||||
parseurl "~1.3.2"
|
||||
send "0.16.1"
|
||||
|
||||
serve-static@^1.13.1:
|
||||
serve-static@^1.13.2:
|
||||
version "1.13.2"
|
||||
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.2.tgz#095e8472fd5b46237db50ce486a43f4b86c6cec1"
|
||||
dependencies:
|
||||
@ -6855,7 +6855,7 @@ simple-swizzle@^0.2.2:
|
||||
dependencies:
|
||||
is-arrayish "^0.3.1"
|
||||
|
||||
sinon@^4.2.2:
|
||||
sinon@^4.3.0:
|
||||
version "4.4.2"
|
||||
resolved "https://registry.yarnpkg.com/sinon/-/sinon-4.4.2.tgz#c4c41d4bd346e1d33594daec2d5df0548334fc65"
|
||||
dependencies:
|
||||
@ -7451,7 +7451,7 @@ uglify-es@^3.3.4:
|
||||
commander "~2.13.0"
|
||||
source-map "~0.6.1"
|
||||
|
||||
uglify-js@3.3.x, uglify-js@^3.3.9:
|
||||
uglify-js@3.3.x, uglify-js@^3.3.10:
|
||||
version "3.3.12"
|
||||
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.12.tgz#efd87c16a1f4c674a8a5ede571001ef634dcc883"
|
||||
dependencies:
|
||||
@ -7715,7 +7715,7 @@ vue-loader@^14.1.1:
|
||||
vue-style-loader "^4.0.1"
|
||||
vue-template-es2015-compiler "^1.6.0"
|
||||
|
||||
vue-meta@^1.4.2:
|
||||
vue-meta@^1.4.3:
|
||||
version "1.4.3"
|
||||
resolved "https://registry.yarnpkg.com/vue-meta/-/vue-meta-1.4.3.tgz#ad0e618c0152617ec7497d9edb117e1a9d70cfc9"
|
||||
dependencies:
|
||||
@ -7801,7 +7801,7 @@ webpack-bundle-analyzer@^2.10.0:
|
||||
opener "^1.4.3"
|
||||
ws "^4.0.0"
|
||||
|
||||
webpack-dev-middleware@^2.0.4:
|
||||
webpack-dev-middleware@^2.0.5:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-2.0.6.tgz#a51692801e8310844ef3e3790e1eacfe52326fd4"
|
||||
dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user