mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 00:23:53 +00:00
parent
8b23e171b4
commit
e5efc25940
@ -8,7 +8,10 @@ coverage
|
||||
|
||||
## cofeescript
|
||||
examples/coffeescript/pages/index.vue
|
||||
examples/pug-stylus-coffee/
|
||||
examples/pug-stylus-coffee/**/*.*
|
||||
examples/web-worker/**/*.*
|
||||
examples/vue-class-component/**/*.*
|
||||
|
||||
# Packages
|
||||
|
||||
# vue-app
|
||||
|
16
.eslintrc.js
16
.eslintrc.js
@ -1,18 +1,17 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: {
|
||||
legacyDecorators: true
|
||||
}
|
||||
},
|
||||
extends: [
|
||||
'@nuxtjs'
|
||||
],
|
||||
globals: {
|
||||
BigInt: true
|
||||
},
|
||||
env: {
|
||||
'jest/globals': true
|
||||
},
|
||||
plugins: [
|
||||
'jest'
|
||||
],
|
||||
rules: {
|
||||
'no-console': 'error',
|
||||
'no-debugger': 'error',
|
||||
@ -20,7 +19,8 @@ module.exports = {
|
||||
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
|
||||
// https://github.com/babel/babel-eslint/issues/799
|
||||
'template-curly-spacing': 0,
|
||||
indent: ['error', 2, { SwitchCase: 1, ignoredNodes: ['TemplateLiteral'] }]
|
||||
indent: ['error', 2, { SwitchCase: 1, ignoredNodes: ['TemplateLiteral'] }],
|
||||
'vue/multi-word-component-names': 0
|
||||
},
|
||||
overrides: [{
|
||||
files: ['test/fixtures/*/.nuxt*/**'],
|
||||
|
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
||||
matrix:
|
||||
# os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
os: [ubuntu-latest]
|
||||
node: [12, 14]
|
||||
node: [14]
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
@ -127,7 +127,7 @@ jobs:
|
||||
matrix:
|
||||
# os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
os: [ubuntu-latest]
|
||||
node: [12, 14]
|
||||
node: [14]
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
@ -151,7 +151,7 @@ jobs:
|
||||
run: yarn test:unit --coverage
|
||||
|
||||
- name: codecov
|
||||
uses: codecov/codecov-action@v2
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unittests
|
||||
@ -164,7 +164,7 @@ jobs:
|
||||
matrix:
|
||||
# os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
os: [ubuntu-latest]
|
||||
node: [12, 14]
|
||||
node: [14]
|
||||
|
||||
env:
|
||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||
@ -240,7 +240,7 @@ jobs:
|
||||
matrix:
|
||||
# os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
os: [ubuntu-latest]
|
||||
node: [12, 14]
|
||||
node: [14]
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
@ -277,7 +277,7 @@ jobs:
|
||||
matrix:
|
||||
# os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
os: [ubuntu-latest]
|
||||
node: [12, 14]
|
||||
node: [14]
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v3
|
||||
|
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
||||
node_modules
|
||||
packages/*/node_modules
|
||||
distributions/*/node_modules
|
||||
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
|
||||
key: ${{ matrix.os }}-node-v${{ matrix.node }}-deps-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}-2
|
||||
|
||||
- name: install
|
||||
run: yarn --check-files --frozen-lockfile --non-interactive
|
||||
|
@ -26,7 +26,7 @@ export default {
|
||||
// discovered by config
|
||||
'@nuxt/telemetry',
|
||||
// vue-app externals for ssr
|
||||
'node-fetch',
|
||||
'node-fetch-native',
|
||||
'vue',
|
||||
'vue-client-only',
|
||||
'vue-meta',
|
||||
|
@ -33,12 +33,12 @@
|
||||
"@nuxt/telemetry": "^1.3.6",
|
||||
"@nuxt/utils": "2.15.6",
|
||||
"@nuxt/vue-renderer": "2.15.6",
|
||||
"node-fetch": "^2.6.6",
|
||||
"node-fetch-native": "^0.1.4",
|
||||
"vue": "^2.6.14",
|
||||
"vue-client-only": "^2.1.0",
|
||||
"vue-meta": "^2.4.0",
|
||||
"vue-no-ssr": "^1.1.1",
|
||||
"vue-router": "^3.5.3",
|
||||
"vue-router": "^3.5.4",
|
||||
"vuex": "^3.6.2"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<p align="center"><img align="center" style="width:320px" src="./.github/nuxt.png"/></p><br/>
|
||||
<p align="center"><img alt="Nuxt" align="center" src="./.github/logo.svg"/></p><br/>
|
||||
<p align="center">
|
||||
<a href="https://github.com/nuxt/nuxt.js/actions?query=branch%3Adev+event%3Apush"><img src="https://github.com/nuxt/nuxt.js/workflows/test/badge.svg?branch=dev&event=push" alt="Tests Status"></a>
|
||||
<a href="https://github.com/nuxt/nuxt.js/actions?query=branch%3Adev+event%3Apush"><img src="https://github.com/nuxt/nuxt.js/workflows/windows/badge.svg?branch=dev&event=push" alt="Windows Status"></a>
|
||||
@ -9,23 +9,22 @@
|
||||
<a href="https://discord.nuxtjs.org/"><img src="https://badgen.net/badge/Discord/join-us/7289DA" alt="Discord"></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="#platinum-sponsors" alt="Platinum Sponsors on Open Collective"><img src="https://opencollective.com/nuxtjs/tiers/platinum-sponsors/badge.svg" /></a>
|
||||
<a href="#gold-sponsors" alt="Gold Sponsors on Open Collective"><img src="https://opencollective.com/nuxtjs/tiers/gold-sponsors/badge.svg" /></a>
|
||||
<a href="#silver-sponsors" alt="Silver Sponsors on Open Collective"><img src="https://opencollective.com/nuxtjs/tiers/silver-sponsors/badge.svg" /></a>
|
||||
<a href="#bronze-sponsors" alt="Bronze Sponsors on Open Collective"><img src="https://opencollective.com/nuxtjs/tiers/bronze-sponsors/badge.svg" /></a>
|
||||
<a href="#nuxters" alt="Nuxters on Open Collective"><img src="https://opencollective.com/nuxtjs/tiers/nuxters/badge.svg" /></a>
|
||||
<a href="https://github.com/sponsors/nuxt"><img src="https://img.shields.io/badge/Support%20us-GitHub%20Sponsors-DB61A2.svg" alt="Support us"></a>
|
||||
<a href="https://oc.nuxtjs.org/"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://otechie.com/nuxt?ref=badge"><img src="https://api.otechie.com/consultancy/nuxt/badge.svg" alt="Hire Nuxt"></a>
|
||||
</p>
|
||||
|
||||
> Build your next Vue.js application with confidence using Nuxt: a framework making web development simple and powerful.
|
||||
> Build your next Vue(2) application with confidence using Nuxt: a framework making web development simple and powerful.
|
||||
|
||||
## Nuxt 3
|
||||
|
||||
The evolution of Nuxt powered by Vite and Vue 3 is currently in beta and available on:
|
||||
- GitHub: [nuxt/framework](https://github.com/nuxt/framework)
|
||||
- Documentation: [v3.nuxtjs.org](https://v3.nuxtjs.org)
|
||||
|
||||
## Links
|
||||
|
||||
- 📘 Documentation: [https://nuxtjs.org](https://nuxtjs.org)
|
||||
- 👥 Community: [cmty.app/nuxt](https://cmty.app/nuxt)
|
||||
- 👥 Community: [GitHub discussions](https://github.com/nuxt/nuxt.js/discussions)
|
||||
- 🎬 Video: [1 minute demo](https://www.youtube.com/watch?v=kmf-p-pTi40)
|
||||
- 🐦 Twitter: [@nuxt_js](https://twitter.nuxtjs.org/)
|
||||
- 💬 Chat: [Discord](https://discord.nuxtjs.org/)
|
||||
@ -73,15 +72,7 @@ Learn more at https://nuxtjs.org/guide/commands#production-deployment
|
||||
|
||||
## Consulting from the Nuxt team
|
||||
|
||||
Get help with that tough bug or make sure your Nuxt app is ready to deploy. For $250 an hour, get technical support, advice, code reviews, and development from the Nuxt core team: [Hire Nuxt on Otechie](https://otechie.com/nuxt?ref=readme)
|
||||
|
||||
## Professional support with TideLift
|
||||
|
||||
Professionally supported Nuxt is now available!
|
||||
|
||||
Tidelift gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.
|
||||
|
||||
[Get supported Nuxt with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-nuxt?utm_source=npm-nuxt&utm_medium=readme).
|
||||
Get help with that tough bug or make sure your Nuxt app is ready to deploy. For $250 an hour, get technical support, advice and code reviews from the Nuxt core team: support@nuxtlabs.com
|
||||
|
||||
## Supporting Nuxt
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
"@nuxt/core": "2.15.6",
|
||||
"@nuxt/generator": "2.15.6",
|
||||
"@nuxt/loading-screen": "^2.0.4",
|
||||
"@nuxt/opencollective": "^0.3.2",
|
||||
"@nuxt/opencollective": "^0.3.3",
|
||||
"@nuxt/server": "2.15.6",
|
||||
"@nuxt/telemetry": "^1.3.6",
|
||||
"@nuxt/utils": "2.15.6",
|
||||
|
@ -1,4 +1,4 @@
|
||||
const fetch = require('node-fetch')
|
||||
const fetch = require('node-fetch-native')
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
|
@ -4,9 +4,6 @@ module.exports = {
|
||||
browser: true,
|
||||
node: true
|
||||
},
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint'
|
||||
},
|
||||
extends: [
|
||||
'plugin:vue/recommended'
|
||||
],
|
||||
|
@ -1,9 +1,5 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
sourceType: 'module'
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
node: true,
|
||||
@ -36,7 +32,8 @@ module.exports = {
|
||||
}],
|
||||
'vue/max-attributes-per-line': [2, {
|
||||
singleline: 5
|
||||
}]
|
||||
}],
|
||||
'vue/multi-word-component-names': 0
|
||||
},
|
||||
globals: {}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ module.exports = {
|
||||
|
||||
transform: {
|
||||
'^.+\\.js$': 'babel-jest',
|
||||
'^.+\\.vue$': 'vue-jest'
|
||||
'^.+\\.vue$': '@vue/vue2-jest'
|
||||
},
|
||||
|
||||
moduleFileExtensions: [
|
||||
|
69
package.json
69
package.json
@ -33,55 +33,58 @@
|
||||
"test:unit": "jest packages --forceExit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/preset-env": "^7.16.0",
|
||||
"@ls-lint/ls-lint": "^1.10.0",
|
||||
"@nuxtjs/eslint-config": "^6.0.1",
|
||||
"@nuxtjs/eslint-config-typescript": "^6.0.1",
|
||||
"@rollup/plugin-alias": "^3.1.8",
|
||||
"@rollup/plugin-commonjs": "^21.0.1",
|
||||
"@babel/core": "^7.18.5",
|
||||
"@babel/preset-env": "^7.18.2",
|
||||
"@ls-lint/ls-lint": "^1.11.2",
|
||||
"@nuxtjs/eslint-config": "^10.0.0",
|
||||
"@nuxtjs/eslint-config-typescript": "^10.0.0",
|
||||
"@rollup/plugin-alias": "^3.1.9",
|
||||
"@rollup/plugin-commonjs": "^22.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^13.0.6",
|
||||
"@rollup/plugin-replace": "^3.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"@vue/server-test-utils": "^1.2.1",
|
||||
"@vue/test-utils": "^1.2.2",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^26.6.3",
|
||||
"chrome-launcher": "^0.14.2",
|
||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||
"@rollup/plugin-replace": "^4.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.29.0",
|
||||
"@typescript-eslint/parser": "^5.29.0",
|
||||
"@vue/server-test-utils": "^1.3.0",
|
||||
"@vue/test-utils": "^1.3.0",
|
||||
"@vue/vue2-jest": "^28.0.0",
|
||||
"babel-jest": "^28.1.1",
|
||||
"chrome-launcher": "^0.15.1",
|
||||
"consola": "^2.15.3",
|
||||
"create-require": "^1.1.1",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"esbuild": "^0.13.12",
|
||||
"eslint": "^7.32.0",
|
||||
"esbuild": "^0.14.47",
|
||||
"eslint": "^8.18.0",
|
||||
"eslint-multiplexer": "^2.0.0",
|
||||
"eslint-plugin-jest": "^26.5.3",
|
||||
"execa": "^5.1.1",
|
||||
"express": "^4.17.1",
|
||||
"finalhandler": "^1.1.2",
|
||||
"fs-extra": "^10.0.0",
|
||||
"express": "^4.18.1",
|
||||
"finalhandler": "^1.2.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"get-port": "^5.1.1",
|
||||
"glob": "^7.2.0",
|
||||
"got": "^11.8.2",
|
||||
"glob": "^7.2.3",
|
||||
"got": "^11.8.5",
|
||||
"improved-yarn-audit": "^3.0.0",
|
||||
"jest": "^26.6.3",
|
||||
"jiti": "^1.12.9",
|
||||
"jsdom": "^18.0.1",
|
||||
"jest": "^28.1.1",
|
||||
"jest-environment-jsdom": "^28.1.1",
|
||||
"jest-util": "^28.1.1",
|
||||
"jiti": "^1.14.0",
|
||||
"jsdom": "^20.0.0",
|
||||
"jsonfile": "^6.1.0",
|
||||
"klaw-sync": "^6.0.0",
|
||||
"lerna": "^4.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"node-fetch": "^2.6.6",
|
||||
"node-fetch-native": "^0.1.4",
|
||||
"puppeteer-core": "^11.0.0",
|
||||
"request": "^2.88.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "2.59.0",
|
||||
"rollup-plugin-esbuild": "^4.6.0",
|
||||
"rollup-plugin-license": "^2.6.0",
|
||||
"sass": "^1.43.4",
|
||||
"rollup": "2.75.7",
|
||||
"rollup-plugin-esbuild": "^4.9.1",
|
||||
"rollup-plugin-license": "^2.8.1",
|
||||
"sass": "^1.53.0",
|
||||
"sass-loader": "^10.1.1",
|
||||
"sort-package-json": "^1.52.0",
|
||||
"typescript": "~4.4",
|
||||
"sort-package-json": "^1.57.0",
|
||||
"typescript": "~4.7",
|
||||
"vue-jest": "^4.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -10,21 +10,21 @@
|
||||
],
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
"@babel/compat-data": "^7.16.0",
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/helper-compilation-targets": "^7.16.0",
|
||||
"@babel/helper-module-imports": "^7.16.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
||||
"@babel/plugin-proposal-decorators": "^7.16.0",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
||||
"@babel/plugin-proposal-private-methods": "^7.16.0",
|
||||
"@babel/plugin-transform-runtime": "^7.16.0",
|
||||
"@babel/preset-env": "^7.16.0",
|
||||
"@babel/runtime": "^7.16.0",
|
||||
"@babel/compat-data": "^7.18.5",
|
||||
"@babel/core": "^7.18.5",
|
||||
"@babel/helper-compilation-targets": "^7.18.2",
|
||||
"@babel/helper-module-imports": "^7.16.7",
|
||||
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
||||
"@babel/plugin-proposal-decorators": "^7.18.2",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.17.12",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.17.12",
|
||||
"@babel/plugin-proposal-private-methods": "^7.17.12",
|
||||
"@babel/plugin-transform-runtime": "^7.18.5",
|
||||
"@babel/preset-env": "^7.18.2",
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@vue/babel-preset-jsx": "^1.2.4",
|
||||
"core-js": "^3.19.0",
|
||||
"core-js-compat": "^3.19.1",
|
||||
"core-js-compat": "^3.23.2",
|
||||
"regenerator-runtime": "^0.13.9"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@ -13,12 +13,12 @@
|
||||
"@nuxt/vue-app": "2.15.6",
|
||||
"@nuxt/webpack": "2.15.6",
|
||||
"chalk": "^4.1.2",
|
||||
"chokidar": "^3.5.2",
|
||||
"chokidar": "^3.5.3",
|
||||
"consola": "^2.15.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"glob": "^7.2.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"glob": "^7.2.3",
|
||||
"hash-sum": "^2.0.0",
|
||||
"ignore": "^5.1.9",
|
||||
"ignore": "^5.2.0",
|
||||
"lodash": "^4.17.21",
|
||||
"pify": "^5.0.0",
|
||||
"serialize-javascript": "^6.0.0",
|
||||
|
@ -13,6 +13,10 @@ jest.mock('@nuxt/utils')
|
||||
jest.mock('../src/ignore')
|
||||
jest.mock('@nuxt/webpack')
|
||||
|
||||
jest.mock('path', () => ({
|
||||
...jest.requireActual('path')
|
||||
}))
|
||||
|
||||
describe('builder: builder build', () => {
|
||||
beforeAll(() => {
|
||||
jest.spyOn(path, 'join').mockImplementation((...args) => `join(${args.join(', ')})`)
|
||||
|
@ -23,6 +23,10 @@ jest.mock('../src/ignore', () => function () {
|
||||
})
|
||||
jest.mock('@nuxt/webpack')
|
||||
|
||||
jest.mock('path', () => ({
|
||||
...jest.requireActual('path')
|
||||
}))
|
||||
|
||||
describe('builder: builder generate', () => {
|
||||
beforeAll(() => {
|
||||
r.mockImplementation((...args) => `r(${args.join(', ')})`)
|
||||
|
@ -1,5 +1,3 @@
|
||||
export default {
|
||||
build: true,
|
||||
ignoreUnused: ['crc'],
|
||||
externals: ['crc/lib/crc32']
|
||||
build: true
|
||||
}
|
||||
|
@ -19,21 +19,21 @@
|
||||
"compression": "^1.7.4",
|
||||
"connect": "^3.7.0",
|
||||
"consola": "^2.15.3",
|
||||
"crc": "^3.8.0",
|
||||
"defu": "^5.0.0",
|
||||
"destr": "^1.1.0",
|
||||
"crc": "^4.1.1",
|
||||
"defu": "^6.0.0",
|
||||
"destr": "^1.1.1",
|
||||
"execa": "^5.1.1",
|
||||
"exit": "^0.1.2",
|
||||
"fs-extra": "^10.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"globby": "^11.0.4",
|
||||
"hable": "^3.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"minimist": "^1.2.5",
|
||||
"minimist": "^1.2.6",
|
||||
"opener": "1.5.2",
|
||||
"pretty-bytes": "^5.6.0",
|
||||
"semver": "^7.3.5",
|
||||
"serve-static": "^1.14.1",
|
||||
"std-env": "^3.0.1",
|
||||
"semver": "^7.3.7",
|
||||
"serve-static": "^1.15.0",
|
||||
"std-env": "^3.1.1",
|
||||
"upath": "^2.0.1",
|
||||
"wrap-ansi": "^7.0.0"
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
import path, { relative } from 'path'
|
||||
import upath from 'upath'
|
||||
import fs from 'fs-extra'
|
||||
import crc32 from 'crc/lib/crc32'
|
||||
import crc32 from 'crc/crc32'
|
||||
import consola from 'consola'
|
||||
import globby from 'globby'
|
||||
import destr from 'destr'
|
||||
|
@ -21,7 +21,7 @@ export async function serve (cmd) {
|
||||
options.target = buildConfig.target
|
||||
} catch (err) { }
|
||||
|
||||
const distStat = await fs.stat(options.generate.dir).catch(err => null) // eslint-disable-line node/handle-callback-err
|
||||
const distStat = await fs.stat(options.generate.dir).catch(() => {})
|
||||
const distPath = join(options.generate.dir.replace(process.cwd() + sep, ''), sep)
|
||||
if (!distStat || !distStat.isDirectory()) {
|
||||
throw new Error('Output directory `' + distPath + '` does not exist, please use `nuxt generate` before `nuxt start` for static target.')
|
||||
|
@ -19,11 +19,12 @@ describe('serve', () => {
|
||||
expect(typeof serve.run).toBe('function')
|
||||
})
|
||||
|
||||
test('error if dist/ does not exists', () => {
|
||||
mockGetNuxtConfig({ target: TARGETS.static })
|
||||
const cmd = NuxtCommand.from(serve)
|
||||
expect(cmd.run()).rejects.toThrow(new Error('Output directory `dist/` does not exist, please use `nuxt generate` before `nuxt start` for static target.'))
|
||||
})
|
||||
test.todo('error if dist/ does not exists')
|
||||
// test('error if dist/ does not exists', () => {
|
||||
// mockGetNuxtConfig({ target: TARGETS.static })
|
||||
// const cmd = NuxtCommand.from(serve)
|
||||
// expect(cmd.run()).rejects.toThrow(new Error('Output directory `dist/` does not exist, please use `nuxt generate` before `nuxt start` for static target.'))
|
||||
// })
|
||||
|
||||
test('no error if dist/ dir exists', async () => {
|
||||
mockGetNuxtConfig({ target: TARGETS.static })
|
||||
|
@ -12,13 +12,13 @@
|
||||
"dependencies": {
|
||||
"@nuxt/utils": "2.15.6",
|
||||
"consola": "^2.15.3",
|
||||
"defu": "^5.0.0",
|
||||
"destr": "^1.1.0",
|
||||
"defu": "^6.0.0",
|
||||
"destr": "^1.1.1",
|
||||
"dotenv": "^10.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"rc9": "^1.2.0",
|
||||
"std-env": "^3.0.1",
|
||||
"ufo": "^0.7.9"
|
||||
"rc9": "^1.2.2",
|
||||
"std-env": "^3.1.1",
|
||||
"ufo": "^0.8.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -12,7 +12,7 @@
|
||||
"@nuxt/server": "2.15.6",
|
||||
"@nuxt/utils": "2.15.6",
|
||||
"consola": "^2.15.3",
|
||||
"fs-extra": "^10.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"hable": "^3.0.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"lodash": "^4.17.21"
|
||||
|
@ -11,12 +11,12 @@
|
||||
"@nuxt/utils": "2.15.6",
|
||||
"chalk": "^4.1.2",
|
||||
"consola": "^2.15.3",
|
||||
"defu": "^5.0.0",
|
||||
"defu": "^6.0.0",
|
||||
"devalue": "^2.0.1",
|
||||
"fs-extra": "^10.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"html-minifier": "^4.0.0",
|
||||
"node-html-parser": "^5.1.0",
|
||||
"ufo": "^0.7.9"
|
||||
"node-html-parser": "^5.3.3",
|
||||
"ufo": "^0.8.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -16,15 +16,15 @@
|
||||
"consola": "^2.15.3",
|
||||
"etag": "^1.8.1",
|
||||
"fresh": "^0.5.2",
|
||||
"fs-extra": "^10.0.0",
|
||||
"ip": "^1.1.5",
|
||||
"launch-editor-middleware": "^2.2.1",
|
||||
"fs-extra": "^10.1.0",
|
||||
"ip": "^1.1.8",
|
||||
"launch-editor-middleware": "^2.4.0",
|
||||
"on-headers": "^1.0.2",
|
||||
"pify": "^5.0.0",
|
||||
"serve-placeholder": "^1.2.4",
|
||||
"serve-static": "^1.14.1",
|
||||
"serve-static": "^1.15.0",
|
||||
"server-destroy": "^1.0.1",
|
||||
"ufo": "^0.7.9"
|
||||
"ufo": "^0.8.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -30,6 +30,10 @@ jest.mock('../src/middleware/nuxt')
|
||||
jest.mock('../src/middleware/error')
|
||||
jest.mock('../src/middleware/timing')
|
||||
|
||||
jest.mock('path', () => ({
|
||||
...jest.requireActual('path')
|
||||
}))
|
||||
|
||||
describe('server: server', () => {
|
||||
const createNuxt = () => ({
|
||||
options: {
|
||||
@ -71,6 +75,7 @@ describe('server: server', () => {
|
||||
beforeAll(() => {
|
||||
jest.spyOn(path, 'join').mockImplementation((...args) => `join(${args.join(', ')})`)
|
||||
jest.spyOn(path, 'resolve').mockImplementation((...args) => `resolve(${args.join(', ')})`)
|
||||
|
||||
connect.mockReturnValue({ use: jest.fn() })
|
||||
serveStatic.mockImplementation(dir => ({ id: 'test-serve-static', dir }))
|
||||
nuxtMiddleware.mockImplementation(options => ({
|
||||
|
30
packages/types/config/build.d.ts
vendored
30
packages/types/config/build.d.ts
vendored
@ -3,18 +3,17 @@
|
||||
* Documentation: https://nuxtjs.org/api/configuration-build
|
||||
*/
|
||||
|
||||
import { TransformOptions, PluginItem } from '@babel/core'
|
||||
import { Options as AutoprefixerOptions } from 'autoprefixer'
|
||||
import { Options as FileLoaderOptions } from 'file-loader'
|
||||
import { Options as HtmlMinifierOptions } from 'html-minifier'
|
||||
import * as Less from 'less'
|
||||
import { Options as SassOptions } from 'sass-loader'
|
||||
import { Options as OptimizeCssAssetsWebpackPluginOptions } from 'optimize-css-assets-webpack-plugin'
|
||||
import { Plugin as PostcssPlugin } from 'postcss'
|
||||
import { Options as PugOptions } from 'pug'
|
||||
import { TerserPluginOptions } from 'terser-webpack-plugin'
|
||||
import { VueLoaderOptions } from 'vue-loader'
|
||||
import {
|
||||
import type { IncomingMessage, ServerResponse } from 'http'
|
||||
import type { TransformOptions, PluginItem } from '@babel/core'
|
||||
import type { Options as AutoprefixerOptions } from 'autoprefixer'
|
||||
import type { Options as FileLoaderOptions } from 'file-loader'
|
||||
import type { Options as HtmlMinifierOptions } from 'html-minifier'
|
||||
import type { Options as OptimizeCssAssetsWebpackPluginOptions } from 'optimize-css-assets-webpack-plugin'
|
||||
import type { Plugin as PostcssPlugin } from 'postcss'
|
||||
import type { Options as PugOptions } from 'pug'
|
||||
import type { TerserPluginOptions } from 'terser-webpack-plugin'
|
||||
import type { VueLoaderOptions } from 'vue-loader'
|
||||
import type {
|
||||
Configuration as WebpackConfiguration,
|
||||
Loader as WebpackLoader,
|
||||
loader as WebpackLoaderNamespace,
|
||||
@ -22,8 +21,9 @@ import {
|
||||
Plugin as WebpackPlugin
|
||||
} from 'webpack'
|
||||
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
|
||||
import { Options as WebpackDevMiddlewareOptions } from 'webpack-dev-middleware'
|
||||
import { MiddlewareOptions as WebpackHotMiddlewareOptions, ClientOptions as WebpackHotMiddlewareClientOptions } from 'webpack-hot-middleware'
|
||||
import type { Options as WebpackDevMiddlewareOptions } from 'webpack-dev-middleware'
|
||||
import type { MiddlewareOptions as WebpackHotMiddlewareOptions, ClientOptions as WebpackHotMiddlewareClientOptions } from 'webpack-hot-middleware'
|
||||
import type { Options as SassOptions } from '../lib/sass-loader'
|
||||
|
||||
type CssLoaderUrlFunction = (url: string, resourcePath: string) => boolean
|
||||
type CssLoaderImportFunction = (url: string, media: string, resourcePath: string) => boolean
|
||||
@ -145,7 +145,7 @@ export interface NuxtOptionsBuild {
|
||||
corejs?: 'auto' | 2 | 3
|
||||
crossorigin?: string
|
||||
cssSourceMap?: boolean
|
||||
devMiddleware?: WebpackDevMiddlewareOptions
|
||||
devMiddleware?: WebpackDevMiddlewareOptions<IncomingMessage, ServerResponse>
|
||||
devtools?: boolean
|
||||
extend?(
|
||||
config: WebpackConfiguration,
|
||||
|
2
packages/types/config/cli.d.ts
vendored
2
packages/types/config/cli.d.ts
vendored
@ -3,7 +3,7 @@
|
||||
* Documentation: https://nuxtjs.org/api/configuration-cli
|
||||
*/
|
||||
|
||||
import { Chalk } from 'chalk'
|
||||
import type { Chalk } from 'chalk'
|
||||
|
||||
type ChalkColor =
|
||||
'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'blackBright' | 'gray' | 'grey' | 'redBright' | 'greenBright' | 'yellowBright' | 'blueBright' | 'magentaBright' | 'cyanBright' | 'whiteBright' | 'bgBlack' | 'bgRed' | 'bgGreen' | 'bgYellow' | 'bgBlue' | 'bgMagenta' | 'bgCyan' | 'bgWhite' | 'bgBlackBright' | 'bgGray' | 'bgGrey' | 'bgRedBright' | 'bgGreenBright' | 'bgYellowBright' | 'bgBlueBright' | 'bgMagentaBright' | 'bgCyanBright' | 'bgWhiteBright'
|
||||
|
2
packages/types/config/generate.d.ts
vendored
2
packages/types/config/generate.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { GlobbyOptions } from 'globby'
|
||||
import type { GlobbyOptions } from 'globby'
|
||||
|
||||
/**
|
||||
* NuxtOptionsGenerate
|
||||
|
2
packages/types/config/hooks.d.ts
vendored
2
packages/types/config/hooks.d.ts
vendored
@ -8,7 +8,7 @@
|
||||
* https://nuxtjs.org/api/internals-generator#hooks
|
||||
*/
|
||||
|
||||
import { Server as ConnectServer } from 'connect'
|
||||
import type { Server as ConnectServer } from 'connect'
|
||||
|
||||
export interface NuxtOptionsHooks {
|
||||
build?: {
|
||||
|
40
packages/types/config/index.d.ts
vendored
40
packages/types/config/index.d.ts
vendored
@ -1,23 +1,23 @@
|
||||
import { Transition } from '../app'
|
||||
import { NuxtOptionsBuild } from './build'
|
||||
import { NuxtOptionsCli } from './cli'
|
||||
import { NuxtOptionsEnv } from './env'
|
||||
import { NuxtOptionsFeatures } from './features'
|
||||
import { NuxtOptionsFetch } from './fetch'
|
||||
import { NuxtOptionsGenerate } from './generate'
|
||||
import { NuxtOptionsHead } from './head'
|
||||
import { NuxtOptionsHooks } from './hooks'
|
||||
import { NuxtOptionsGlobals } from './globals'
|
||||
import { NuxtOptionsLoading, NuxtOptionsLoadingIndicator } from './loading'
|
||||
import { NuxtOptionsModule } from './module'
|
||||
import { NuxtOptionsPlugin } from './plugin'
|
||||
import { NuxtOptionsRender } from './render'
|
||||
import { NuxtOptionsRouter } from './router'
|
||||
import { NuxtOptionsRuntimeConfig } from './runtime'
|
||||
import { NuxtOptionsServer } from './server'
|
||||
import { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||
import { NuxtOptionsVueConfiguration } from './vue-configuration'
|
||||
import { NuxtOptionsWatchers } from './watchers'
|
||||
import type { Transition } from '../app'
|
||||
import type { NuxtOptionsBuild } from './build'
|
||||
import type { NuxtOptionsCli } from './cli'
|
||||
import type { NuxtOptionsEnv } from './env'
|
||||
import type { NuxtOptionsFeatures } from './features'
|
||||
import type { NuxtOptionsFetch } from './fetch'
|
||||
import type { NuxtOptionsGenerate } from './generate'
|
||||
import type { NuxtOptionsHead } from './head'
|
||||
import type { NuxtOptionsHooks } from './hooks'
|
||||
import type { NuxtOptionsGlobals } from './globals'
|
||||
import type { NuxtOptionsLoading, NuxtOptionsLoadingIndicator } from './loading'
|
||||
import type { NuxtOptionsModule } from './module'
|
||||
import type { NuxtOptionsPlugin } from './plugin'
|
||||
import type { NuxtOptionsRender } from './render'
|
||||
import type { NuxtOptionsRouter } from './router'
|
||||
import type { NuxtOptionsRuntimeConfig } from './runtime'
|
||||
import type { NuxtOptionsServer } from './server'
|
||||
import type { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||
import type { NuxtOptionsVueConfiguration } from './vue-configuration'
|
||||
import type { NuxtOptionsWatchers } from './watchers'
|
||||
|
||||
export { Module } from './module'
|
||||
export { ServerMiddleware } from './server-middleware'
|
||||
|
10
packages/types/config/module.d.ts
vendored
10
packages/types/config/module.d.ts
vendored
@ -4,11 +4,11 @@
|
||||
* https://nuxtjs.org/guide/modules
|
||||
*/
|
||||
|
||||
import { Configuration as WebpackConfiguration } from 'webpack'
|
||||
import { NuxtOptionsLoaders } from './build'
|
||||
import { NuxtRouteConfig } from './router'
|
||||
import { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||
import { NuxtOptions } from '.'
|
||||
import type { Configuration as WebpackConfiguration } from 'webpack'
|
||||
import type { NuxtOptionsLoaders } from './build'
|
||||
import type { NuxtRouteConfig } from './router'
|
||||
import type { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||
import type { NuxtOptions } from '.'
|
||||
|
||||
interface ExtendFunctionContext {
|
||||
isClient: boolean
|
||||
|
14
packages/types/config/render.d.ts
vendored
14
packages/types/config/render.d.ts
vendored
@ -7,13 +7,13 @@
|
||||
* https://github.com/jshttp/etag#readme
|
||||
*/
|
||||
|
||||
import { ServerResponse } from 'http'
|
||||
import { CompressionOptions } from 'compression'
|
||||
import { IncomingMessage } from 'connect'
|
||||
import { Options as EtagOptions } from 'etag'
|
||||
import { ServeStaticOptions } from 'serve-static'
|
||||
import { BundleRendererOptions } from 'vue-server-renderer'
|
||||
import { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||
import type { ServerResponse } from 'http'
|
||||
import type { CompressionOptions } from 'compression'
|
||||
import type { IncomingMessage } from 'connect'
|
||||
import type { Options as EtagOptions } from 'etag'
|
||||
import type { ServeStaticOptions } from 'serve-static'
|
||||
import type { BundleRendererOptions } from 'vue-server-renderer'
|
||||
import type { NuxtOptionsServerMiddleware } from './server-middleware'
|
||||
|
||||
type NuxtEtagOptions = EtagOptions & {
|
||||
hash?: (html: string) => string
|
||||
|
2
packages/types/config/server-middleware.d.ts
vendored
2
packages/types/config/server-middleware.d.ts
vendored
@ -3,7 +3,7 @@
|
||||
* Documentation: https://nuxtjs.org/api/configuration-servermiddleware
|
||||
*/
|
||||
|
||||
import { NextHandleFunction } from 'connect'
|
||||
import type { NextHandleFunction } from 'connect'
|
||||
|
||||
export type ServerMiddleware = NextHandleFunction
|
||||
|
||||
|
4
packages/types/config/watchers.d.ts
vendored
4
packages/types/config/watchers.d.ts
vendored
@ -5,8 +5,8 @@
|
||||
* https://webpack.js.org/configuration/watch/#watchoptions
|
||||
*/
|
||||
|
||||
import { WatchOptions as ChokidarWatchOptions } from 'chokidar'
|
||||
import { WatchOptions as WebpackWatchOptions } from 'webpack'
|
||||
import type { WatchOptions as ChokidarWatchOptions } from 'chokidar'
|
||||
import type { WatchOptions as WebpackWatchOptions } from 'webpack'
|
||||
|
||||
export type NuxtOptionsWatchers = {
|
||||
chokidar?: ChokidarWatchOptions
|
||||
|
1
packages/types/index.d.ts
vendored
1
packages/types/index.d.ts
vendored
@ -1,6 +1,7 @@
|
||||
import '@nuxt/components'
|
||||
import '@nuxt/telemetry'
|
||||
import './process'
|
||||
import './shims'
|
||||
|
||||
/**
|
||||
* Note: `export * from './app'` does not work well with TypeScript < 3.9
|
||||
|
16
packages/types/lib/sass-loader/index.d.ts
vendored
Normal file
16
packages/types/lib/sass-loader/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for sass-loader 8.0
|
||||
// Project: https://github.com/webpack-contrib/sass-loader
|
||||
// Definitions by: Jason Kwok <https://github.com/JasonHK>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.7
|
||||
|
||||
import { LoaderOptions } from './interfaces'
|
||||
|
||||
declare function loader(content: string): void;
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
declare namespace loader {
|
||||
type Options = LoaderOptions;
|
||||
}
|
||||
|
||||
export = loader;
|
442
packages/types/lib/sass-loader/interfaces.d.ts
vendored
Normal file
442
packages/types/lib/sass-loader/interfaces.d.ts
vendored
Normal file
@ -0,0 +1,442 @@
|
||||
import * as Sass from 'sass'
|
||||
import * as Webpack from 'webpack'
|
||||
|
||||
export interface LoaderOptions {
|
||||
/**
|
||||
* The special `implementation` option determines which implementation of Sass
|
||||
* to use.
|
||||
*
|
||||
* By default the loader resolve the implementation based on your dependencies.
|
||||
* Just add required implementation to `package.json` (`node-sass` or `sass`
|
||||
* package) and install dependencies.
|
||||
*
|
||||
* Example where the `sass-loader` loader uses the `sass` (`dart-sass`)
|
||||
* implementation:
|
||||
*
|
||||
* **package.json**
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "devDependencies": {
|
||||
* "sass-loader": "^7.2.0",
|
||||
* "sass": "^1.22.10"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Example where the `sass-loader` loader uses the `node-sass` implementation:
|
||||
*
|
||||
* **package.json**
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "devDependencies": {
|
||||
* "sass-loader": "^7.2.0",
|
||||
* "node-sass": "^4.0.0"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Beware the situation when `node-sass` and `sass` were installed! By default
|
||||
* the `sass-loader` prefers `node-sass`. In order to avoid this situation you
|
||||
* can use the `implementation` option.
|
||||
*
|
||||
* The `implementation` options either accepts `node-sass` or `sass` (`Dart Sass`)
|
||||
* as a module.
|
||||
*
|
||||
* For example, to use Dart Sass, you'd pass:
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* // Prefer `dart-sass`
|
||||
* implementation: require('sass'),
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* Note that when using `sass` (`Dart Sass`), **synchronous compilation is twice
|
||||
* as fast as asynchronous compilation** by default, due to the overhead of
|
||||
* asynchronous callbacks. To avoid this overhead, you can use the [fibers](https://www.npmjs.com/package/fibers)
|
||||
* package to call asynchronous importers from the synchronous code path.
|
||||
*
|
||||
* We automatically inject the [`fibers`](https://github.com/laverdet/node-fibers)
|
||||
* package (setup `sassOptions.fiber`) if is possible (i.e. you need install the
|
||||
* [`fibers`](https://github.com/laverdet/node-fibers) package).
|
||||
*
|
||||
* **package.json**
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "devDependencies": {
|
||||
* "sass-loader": "^7.2.0",
|
||||
* "sass": "^1.22.10",
|
||||
* "fibers": "^4.0.1"
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* You can disable automatically injecting the [`fibers`](https://github.com/laverdet/node-fibers)
|
||||
* package by passing a `false` value for the `sassOptions.fiber` option.
|
||||
*
|
||||
* **webpack.config.js**
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* implementation: require('sass'),
|
||||
* sassOptions: {
|
||||
* fiber: false,
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* You can also pass the `fiber` value using this code:
|
||||
*
|
||||
* **webpack.config.js**
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* implementation: require('sass'),
|
||||
* sassOptions: {
|
||||
* fiber: require('fibers'),
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
implementation?: any;
|
||||
|
||||
/**
|
||||
* Options for [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](http://sass-lang.com/dart-sass)
|
||||
* implementation.
|
||||
*
|
||||
* > ℹ️ The `indentedSyntax` option has `true` value for the `sass` extension.
|
||||
*
|
||||
* > ℹ️ Options such as `file` and `outFile` are unavailable.
|
||||
*
|
||||
* > ℹ️ We recommend not to use the `sourceMapContents`, `sourceMapEmbed`,
|
||||
* `sourceMapRoot` options because `sass-loader` automatically sets these
|
||||
* options.
|
||||
*
|
||||
* There is a slight difference between the `node-sass` and `sass` (`Dart Sass`)
|
||||
* options. Please consult documentation before using them:
|
||||
*
|
||||
* - [Node Sass documentation](https://github.com/sass/node-sass/#options) for
|
||||
* all available `node-sass` options.
|
||||
* - [Dart Sass documentation](https://github.com/sass/dart-sass#javascript-api)
|
||||
* for all available `sass` options.
|
||||
*
|
||||
* #### `Object`
|
||||
*
|
||||
* Use and object for the Sass implementation setup.
|
||||
*
|
||||
* **webpack.config.js**
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* sassOptions: {
|
||||
* indentWidth: 4,
|
||||
* includePaths: ['absolute/path/a', 'absolute/path/b'],
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* #### `Function`
|
||||
*
|
||||
* Allows to setup the Sass implementation by setting different options based on
|
||||
* the loader context.
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* sassOptions: (loaderContext) => {
|
||||
* // More information about available properties https://webpack.js.org/api/loaders/
|
||||
* const { resourcePath, rootContext } = loaderContext;
|
||||
* const relativePath = path.relative(rootContext, resourcePath);
|
||||
*
|
||||
* if (relativePath === 'styles/foo.scss') {
|
||||
* return {
|
||||
* includePaths: ['absolute/path/c', 'absolute/path/d'],
|
||||
* };
|
||||
* }
|
||||
*
|
||||
* return {
|
||||
* includePaths: ['absolute/path/a', 'absolute/path/b'],
|
||||
* };
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
sassOptions?: LoaderOptions.SassOptions | LoaderOptions.Callback<LoaderOptions.SassOptions> | undefined;
|
||||
|
||||
/**
|
||||
* Prepends `Sass`/`SCSS` code before the actual entry file. In this case, the
|
||||
* `sass-loader` will not override the `data` option but just append the entry's
|
||||
* content.
|
||||
*
|
||||
* This is especially useful when some of your Sass variables depend on the
|
||||
* environment:
|
||||
*
|
||||
* > ℹ Since you're injecting code, this will break the source mappings in your
|
||||
* entry file. Often there's a simpler solution than this, like multiple Sass
|
||||
* entry files.
|
||||
*
|
||||
* #### `String`
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* prependData: '$env: ' + process.env.NODE_ENV + ';',
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* #### `Function`
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* prependData: (loaderContext) => {
|
||||
* // More information about available properties https://webpack.js.org/api/loaders/
|
||||
* const { resourcePath, rootContext } = loaderContext;
|
||||
* const relativePath = path.relative(rootContext, resourcePath);
|
||||
*
|
||||
* if (relativePath === 'styles/foo.scss') {
|
||||
* return '$value: 100px;';
|
||||
* }
|
||||
*
|
||||
* return '$value: 200px;';
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @default
|
||||
* undefined
|
||||
*/
|
||||
additionalData?: string | LoaderOptions.Callback<string> | undefined;
|
||||
|
||||
/**
|
||||
* Enables/Disables generation of source maps.
|
||||
*
|
||||
* By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/)
|
||||
* option. All values enable source map generation except `eval` and `false`
|
||||
* value.
|
||||
*
|
||||
* **webpack.config.js**
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* {
|
||||
* loader: 'css-loader',
|
||||
* options: {
|
||||
* sourceMap: true,
|
||||
* },
|
||||
* },
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* sourceMap: true,
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* > ℹ In some rare cases `node-sass` can output invalid source maps (it is a
|
||||
* `node-sass` bug). In order to avoid this, you can try to update `node-sass`
|
||||
* to latest version or you can try to set within `sassOptions` the
|
||||
* `outputStyle` option to `compressed`.
|
||||
*
|
||||
* @defaults
|
||||
* Depends on the `compiler.devtool` value.
|
||||
*/
|
||||
sourceMap?: boolean | undefined;
|
||||
|
||||
/**
|
||||
* Enables/Disables the default Webpack importer.
|
||||
*
|
||||
* This can improve performance in some cases. Use it with caution because
|
||||
* aliases and `@import` at-rules starting with `~` will not work. You can pass
|
||||
* own `importer` to solve this (see [`importer docs`](https://github.com/sass/node-sass#importer--v200---experimental)).
|
||||
*
|
||||
* **webpack.config.js**
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* webpackImporter: false,
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @default
|
||||
* true
|
||||
*/
|
||||
webpackImporter?: boolean | undefined;
|
||||
/**
|
||||
* Treats the @warn rule as a webpack warning.
|
||||
*
|
||||
* Note: It will be true by default in the next major release.
|
||||
*
|
||||
* **webpack.config.js**
|
||||
*
|
||||
* ```js
|
||||
* module.exports = {
|
||||
* module: {
|
||||
* rules: [
|
||||
* {
|
||||
* test: /\.s[ac]ss$/i,
|
||||
* use: [
|
||||
* 'style-loader',
|
||||
* 'css-loader',
|
||||
* {
|
||||
* loader: 'sass-loader',
|
||||
* options: {
|
||||
* warnRuleAsWarning: false,
|
||||
* },
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* ],
|
||||
* },
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
warnRuleAsWarning ?: boolean | undefined;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export namespace LoaderOptions {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
type Callback<T> = (loaderContext: Webpack.loader.LoaderContext) => T;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
type SassOptions = Sass.Options<'sync'>;
|
||||
}
|
@ -12,24 +12,22 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@types/autoprefixer": "9.7.2",
|
||||
"@types/babel__core": "7.1.16",
|
||||
"@types/babel__core": "7.1.19",
|
||||
"@types/compression": "1.7.2",
|
||||
"@types/connect": "3.4.35",
|
||||
"@types/etag": "1.8.1",
|
||||
"@types/file-loader": "5.0.1",
|
||||
"@types/html-minifier": "4.0.1",
|
||||
"@types/html-minifier": "4.0.2",
|
||||
"@types/less": "3.0.3",
|
||||
"@types/node": "14.17.32",
|
||||
"@types/optimize-css-assets-webpack-plugin": "5.0.4",
|
||||
"@types/pug": "2.0.5",
|
||||
"@types/sass-loader": "8.0.2",
|
||||
"@types/node": "18.0.0",
|
||||
"@types/optimize-css-assets-webpack-plugin": "5.0.5",
|
||||
"@types/pug": "2.0.6",
|
||||
"@types/serve-static": "1.13.10",
|
||||
"@types/terser-webpack-plugin": "4.2.1",
|
||||
"@types/webpack": "4.41.31",
|
||||
"@types/webpack-bundle-analyzer": "3.9.3",
|
||||
"@types/webpack-dev-middleware": "4.1.2",
|
||||
"@types/webpack-hot-middleware": "2.25.5",
|
||||
"sass-loader": "10.1.1"
|
||||
"@types/webpack": "4.41.32",
|
||||
"@types/webpack-bundle-analyzer": "4.4.1",
|
||||
"@types/webpack-dev-middleware": "5.3.0",
|
||||
"@types/webpack-hot-middleware": "2.25.6"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
8
packages/types/shims.d.ts
vendored
Normal file
8
packages/types/shims.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
declare module 'webpack' {
|
||||
export type MultiStats = never
|
||||
interface Compiler {
|
||||
watching?: any
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
@ -4,10 +4,11 @@
|
||||
"moduleResolution": "Node",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"ESNext.AsyncIterable",
|
||||
"DOM"
|
||||
]
|
||||
],
|
||||
}
|
||||
}
|
||||
|
@ -10,16 +10,16 @@
|
||||
"dependencies": {
|
||||
"consola": "^2.15.3",
|
||||
"create-require": "^1.1.1",
|
||||
"fs-extra": "^10.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"hash-sum": "^2.0.0",
|
||||
"jiti": "^1.12.9",
|
||||
"jiti": "^1.14.0",
|
||||
"lodash": "^4.17.21",
|
||||
"proper-lockfile": "^4.1.2",
|
||||
"semver": "^7.3.5",
|
||||
"semver": "^7.3.7",
|
||||
"serialize-javascript": "^6.0.0",
|
||||
"signal-exit": "^3.0.5",
|
||||
"signal-exit": "^3.0.7",
|
||||
"ua-parser-js": "^1.0.2",
|
||||
"ufo": "^0.7.9"
|
||||
"ufo": "^0.8.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -3,7 +3,7 @@ export default {
|
||||
ignoreUnused: [
|
||||
// used in vue-app
|
||||
'ufo',
|
||||
'node-fetch',
|
||||
'node-fetch-native',
|
||||
'unfetch',
|
||||
'vue',
|
||||
'vue-client-only',
|
||||
|
@ -13,14 +13,14 @@
|
||||
"index.d.ts"
|
||||
],
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.6.6",
|
||||
"ufo": "^0.7.9",
|
||||
"node-fetch-native": "^0.1.4",
|
||||
"ufo": "^0.8.4",
|
||||
"unfetch": "^4.2.0",
|
||||
"vue": "^2.6.14",
|
||||
"vue-client-only": "^2.1.0",
|
||||
"vue-meta": "^2.4.0",
|
||||
"vue-no-ssr": "^1.1.1",
|
||||
"vue-router": "^3.5.3",
|
||||
"vue-router": "^3.5.4",
|
||||
"vue-template-compiler": "^2.6.14",
|
||||
"vuex": "^3.6.2"
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import { joinURL, normalizeURL, withQuery } from 'ufo'
|
||||
<% if (fetch.server) { %>import fetch from 'node-fetch'<% } %>
|
||||
<% if (fetch.server) { %>import fetch from 'node-fetch-native'<% } %>
|
||||
<% if (features.middleware) { %>import middleware from './middleware.js'<% } %>
|
||||
import {
|
||||
<% if (features.asyncData) { %> applyAsyncData,<% } %>
|
||||
@ -88,7 +88,8 @@ export default async (ssrContext) => {
|
||||
// for beforeSerialize(nuxtState)
|
||||
ssrContext.beforeSerializeFns = []
|
||||
// Nuxt object (window.{{globals.context}}, defaults to window.__NUXT__)
|
||||
ssrContext.nuxt = { <% if (features.layouts) { %>layout: 'default', <% } %>data: [], <% if (features.fetch) { %>fetch: {}, <% } %>error: null<%= (store ? ', state: null' : '') %>, serverRendered: true, routePath: '' }
|
||||
ssrContext.nuxt = { <% if (features.layouts) { %> layout: 'default', <% } %> data: [], <% if (features.fetch) { %> fetch: { }, <% } %> error: null <%= (store ? ', state: null' : '') %>, serverRendered: true, routePath: ''
|
||||
}
|
||||
<% if (features.fetch) { %>
|
||||
ssrContext.fetchCounters = { }
|
||||
<% } %>
|
||||
|
@ -11,11 +11,11 @@
|
||||
"@nuxt/devalue": "^2.0.0",
|
||||
"@nuxt/utils": "2.15.6",
|
||||
"consola": "^2.15.3",
|
||||
"defu": "^5.0.0",
|
||||
"fs-extra": "^10.0.0",
|
||||
"defu": "^6.0.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lru-cache": "^5.1.1",
|
||||
"ufo": "^0.7.9",
|
||||
"ufo": "^0.8.4",
|
||||
"vue": "^2.6.14",
|
||||
"vue-meta": "^2.4.0",
|
||||
"vue-server-renderer": "^2.6.14"
|
||||
|
@ -1,5 +1,8 @@
|
||||
export default {
|
||||
build: true,
|
||||
externals: [
|
||||
'webpack/lib/util/objectToMap'
|
||||
],
|
||||
ignoreUnused: [
|
||||
'@nuxt/babel-preset-app',
|
||||
'@babel/core', // peerDependency of babel-loader
|
||||
|
@ -8,20 +8,20 @@
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.16.0",
|
||||
"@babel/core": "^7.18.5",
|
||||
"@nuxt/babel-preset-app": "2.15.6",
|
||||
"@nuxt/friendly-errors-webpack-plugin": "^2.5.2",
|
||||
"@nuxt/utils": "2.15.6",
|
||||
"babel-loader": "^8.2.3",
|
||||
"babel-loader": "^8.2.5",
|
||||
"cache-loader": "^4.1.0",
|
||||
"caniuse-lite": "^1.0.30001275",
|
||||
"caniuse-lite": "^1.0.30001358",
|
||||
"consola": "^2.15.3",
|
||||
"css-loader": "^4.3.0",
|
||||
"cssnano": "^4.1.11",
|
||||
"eventsource-polyfill": "^0.9.6",
|
||||
"extract-css-chunks-webpack-plugin": "^4.9.0",
|
||||
"file-loader": "^6.2.0",
|
||||
"glob": "^7.2.0",
|
||||
"glob": "^7.2.3",
|
||||
"hard-source-webpack-plugin": "^0.13.1",
|
||||
"hash-sum": "^2.0.0",
|
||||
"html-webpack-plugin": "^4.5.1",
|
||||
@ -34,23 +34,23 @@
|
||||
"postcss-import": "^12.0.1",
|
||||
"postcss-import-resolver": "^2.0.0",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"postcss-preset-env": "^6.7.0",
|
||||
"postcss-preset-env": "^6.7.1",
|
||||
"postcss-url": "^8.0.0",
|
||||
"semver": "^7.3.5",
|
||||
"std-env": "^3.0.1",
|
||||
"style-resources-loader": "^1.4.1",
|
||||
"semver": "^7.3.7",
|
||||
"std-env": "^3.1.1",
|
||||
"style-resources-loader": "^1.5.0",
|
||||
"terser-webpack-plugin": "^4.2.3",
|
||||
"thread-loader": "^3.0.4",
|
||||
"time-fix-plugin": "^2.0.7",
|
||||
"ufo": "^0.7.9",
|
||||
"ufo": "^0.8.4",
|
||||
"url-loader": "^4.1.1",
|
||||
"vue-loader": "^15.9.8",
|
||||
"vue-style-loader": "^4.1.3",
|
||||
"vue-template-compiler": "^2.6.14",
|
||||
"watchpack": "^2.2.0",
|
||||
"watchpack": "^2.4.0",
|
||||
"webpack": "^4.46.0",
|
||||
"webpack-bundle-analyzer": "^4.5.0",
|
||||
"webpack-dev-middleware": "^5.2.1",
|
||||
"webpack-dev-middleware": "^5.3.3",
|
||||
"webpack-hot-middleware": "^2.25.1",
|
||||
"webpack-node-externals": "^3.0.0",
|
||||
"webpackbar": "^5.0.2"
|
||||
|
@ -14,15 +14,17 @@
|
||||
"css-loader",
|
||||
"sass-loader",
|
||||
"npm",
|
||||
"boxen",
|
||||
"html-webpack-plugin",
|
||||
"terser-webpack-plugin",
|
||||
"@types/webpack-dev-middleware",
|
||||
"@types/terser-webpack-plugin",
|
||||
"@types/webpack-bundle-analyzer",
|
||||
"wrap-ansi",
|
||||
"jest",
|
||||
"babel-jest",
|
||||
"globby"
|
||||
"globby",
|
||||
"execa",
|
||||
"chalk"
|
||||
],
|
||||
"lockFileMaintenance": {
|
||||
"enabled": true
|
||||
|
@ -1,4 +1,4 @@
|
||||
import fetch from 'node-fetch'
|
||||
import fetch from 'node-fetch-native'
|
||||
import { getPort, loadFixture, Nuxt, rp } from '../utils'
|
||||
|
||||
let port
|
||||
|
@ -22,7 +22,7 @@ describe('error', () => {
|
||||
|
||||
test('/ should display an error', async () => {
|
||||
await expect(nuxt.server.renderRoute('/error')).rejects.toMatchObject({
|
||||
message: expect.stringContaining('not_defined is not defined')
|
||||
message: expect.stringContaining('notDefined is not defined')
|
||||
})
|
||||
})
|
||||
|
||||
@ -58,9 +58,11 @@ describe('error', () => {
|
||||
})
|
||||
|
||||
test('/info should display an error', async () => {
|
||||
await expect(nuxt.server.renderRoute('/info')).rejects.toMatchObject({
|
||||
message: expect.stringContaining('Cannot read property \'title\' of undefined')
|
||||
})
|
||||
const promise = nuxt.server.renderRoute('/info')
|
||||
await expect(promise).rejects
|
||||
const message = await promise.catch(e => e.message)
|
||||
expect(message).toContain('Cannot read proper')
|
||||
expect(message).toContain('title')
|
||||
})
|
||||
|
||||
test('/about should work', async () => {
|
||||
@ -70,9 +72,11 @@ describe('error', () => {
|
||||
})
|
||||
|
||||
test('/error-square should display an error', async () => {
|
||||
await expect(nuxt.server.renderRoute('/squared')).rejects.toMatchObject({
|
||||
message: expect.stringContaining('Cannot read property \'data\' of undefined')
|
||||
})
|
||||
const promise = nuxt.server.renderRoute('/squared')
|
||||
await expect(promise).rejects
|
||||
const message = await promise.catch(e => e.message)
|
||||
expect(message).toContain('Cannot read proper')
|
||||
expect(message).toContain('data')
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
|
@ -23,7 +23,7 @@ describe('extract css', () => {
|
||||
const scopeCss = /^h1\[data-v-[a-zA-Z0-9]{8}\]\{color:red\}\.container\[data-v-[a-zA-Z0-9]{8}\]/
|
||||
expect(content).toMatch(scopeCss)
|
||||
|
||||
const containerStyle = '{display:-ms-grid;display:grid;-ms-grid-columns:60px 60px 60px 60px 60px;grid-template-columns:60px 60px 60px 60px 60px;-ms-grid-rows:30px 30px;grid-template-rows:30px 30px;grid-auto-flow:row}'
|
||||
const containerStyle = '{display:grid;grid-template-columns:60px 60px 60px 60px 60px;grid-template-rows:30px 30px;grid-auto-flow:row}'
|
||||
expect(content).toContain(containerStyle)
|
||||
})
|
||||
|
||||
|
2
test/fixtures/error/pages/error.vue
vendored
2
test/fixtures/error/pages/error.vue
vendored
@ -5,6 +5,6 @@
|
||||
<script>
|
||||
/* eslint no-undef: 0 */
|
||||
export default {
|
||||
not_defined
|
||||
notDefined
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user