first commit
This commit is contained in:
269
app_vue/node_modules/@vue/cli-service/lib/config/app.js
generated
vendored
Normal file
269
app_vue/node_modules/@vue/cli-service/lib/config/app.js
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
// config that are specific to --target app
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
// ensure the filename passed to html-webpack-plugin is a relative path
|
||||
// because it cannot correctly handle absolute paths
|
||||
function ensureRelative (outputDir, _path) {
|
||||
if (path.isAbsolute(_path)) {
|
||||
return path.relative(outputDir, _path)
|
||||
} else {
|
||||
return _path
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (api, options) => {
|
||||
api.chainWebpack(webpackConfig => {
|
||||
// only apply when there's no alternative target
|
||||
if (process.env.VUE_CLI_BUILD_TARGET && process.env.VUE_CLI_BUILD_TARGET !== 'app') {
|
||||
return
|
||||
}
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'production'
|
||||
const isLegacyBundle = process.env.VUE_CLI_MODERN_MODE && !process.env.VUE_CLI_MODERN_BUILD
|
||||
const outputDir = api.resolve(options.outputDir)
|
||||
|
||||
const getAssetPath = require('../util/getAssetPath')
|
||||
const outputFilename = getAssetPath(
|
||||
options,
|
||||
`js/[name]${isLegacyBundle ? `-legacy` : ``}${isProd && options.filenameHashing ? '.[contenthash:8]' : ''}.js`
|
||||
)
|
||||
webpackConfig
|
||||
.output
|
||||
.filename(outputFilename)
|
||||
.chunkFilename(outputFilename)
|
||||
|
||||
// FIXME: a temporary workaround to get accurate contenthash in `applyLegacy`
|
||||
// Should use a better fix per discussions at <https://github.com/jantimon/html-webpack-plugin/issues/1554#issuecomment-753653580>
|
||||
webpackConfig.optimization
|
||||
.set('realContentHash', false)
|
||||
|
||||
// code splitting
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
webpackConfig.optimization.splitChunks({
|
||||
cacheGroups: {
|
||||
defaultVendors: {
|
||||
name: `chunk-vendors`,
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: -10,
|
||||
chunks: 'initial'
|
||||
},
|
||||
common: {
|
||||
name: `chunk-common`,
|
||||
minChunks: 2,
|
||||
priority: -20,
|
||||
chunks: 'initial',
|
||||
reuseExistingChunk: true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// HTML plugin
|
||||
const resolveClientEnv = require('../util/resolveClientEnv')
|
||||
|
||||
const htmlOptions = {
|
||||
title: api.service.pkg.name,
|
||||
scriptLoading: 'defer',
|
||||
templateParameters: (compilation, assets, assetTags, pluginOptions) => {
|
||||
// enhance html-webpack-plugin's built in template params
|
||||
return Object.assign({
|
||||
compilation: compilation,
|
||||
webpackConfig: compilation.options,
|
||||
htmlWebpackPlugin: {
|
||||
tags: assetTags,
|
||||
files: assets,
|
||||
options: pluginOptions
|
||||
}
|
||||
}, resolveClientEnv(options, true /* raw */))
|
||||
}
|
||||
}
|
||||
|
||||
// handle indexPath
|
||||
if (options.indexPath !== 'index.html') {
|
||||
// why not set filename for html-webpack-plugin?
|
||||
// 1. It cannot handle absolute paths
|
||||
// 2. Relative paths causes incorrect SW manifest to be generated (#2007)
|
||||
webpackConfig
|
||||
.plugin('move-index')
|
||||
.use(require('../webpack/MovePlugin'), [
|
||||
path.resolve(outputDir, 'index.html'),
|
||||
path.resolve(outputDir, options.indexPath)
|
||||
])
|
||||
}
|
||||
|
||||
// resolve HTML file(s)
|
||||
const HTMLPlugin = require('html-webpack-plugin')
|
||||
// const PreloadPlugin = require('@vue/preload-webpack-plugin')
|
||||
const multiPageConfig = options.pages
|
||||
const htmlPath = api.resolve('public/index.html')
|
||||
const defaultHtmlPath = path.resolve(__dirname, 'index-default.html')
|
||||
const publicCopyIgnore = ['**/.DS_Store']
|
||||
|
||||
if (!multiPageConfig) {
|
||||
// default, single page setup.
|
||||
htmlOptions.template = fs.existsSync(htmlPath)
|
||||
? htmlPath
|
||||
: defaultHtmlPath
|
||||
|
||||
publicCopyIgnore.push(api.resolve(htmlOptions.template).replace(/\\/g, '/'))
|
||||
|
||||
webpackConfig
|
||||
.plugin('html')
|
||||
.use(HTMLPlugin, [htmlOptions])
|
||||
|
||||
// FIXME: need to test out preload plugin's compatibility with html-webpack-plugin 4/5
|
||||
// if (!isLegacyBundle) {
|
||||
// // inject preload/prefetch to HTML
|
||||
// webpackConfig
|
||||
// .plugin('preload')
|
||||
// .use(PreloadPlugin, [{
|
||||
// rel: 'preload',
|
||||
// include: 'initial',
|
||||
// fileBlacklist: [/\.map$/, /hot-update\.js$/]
|
||||
// }])
|
||||
|
||||
// webpackConfig
|
||||
// .plugin('prefetch')
|
||||
// .use(PreloadPlugin, [{
|
||||
// rel: 'prefetch',
|
||||
// include: 'asyncChunks'
|
||||
// }])
|
||||
// }
|
||||
} else {
|
||||
// multi-page setup
|
||||
webpackConfig.entryPoints.clear()
|
||||
|
||||
const pages = Object.keys(multiPageConfig)
|
||||
const normalizePageConfig = c => typeof c === 'string' ? { entry: c } : c
|
||||
|
||||
pages.forEach(name => {
|
||||
const pageConfig = normalizePageConfig(multiPageConfig[name])
|
||||
const {
|
||||
entry,
|
||||
template = `public/${name}.html`,
|
||||
filename = `${name}.html`,
|
||||
chunks = ['chunk-vendors', 'chunk-common', name]
|
||||
} = pageConfig
|
||||
|
||||
// Currently Cypress v3.1.0 comes with a very old version of Node,
|
||||
// which does not support object rest syntax.
|
||||
// (https://github.com/cypress-io/cypress/issues/2253)
|
||||
// So here we have to extract the customHtmlOptions manually.
|
||||
const customHtmlOptions = {}
|
||||
for (const key in pageConfig) {
|
||||
if (
|
||||
!['entry', 'template', 'filename', 'chunks'].includes(key)
|
||||
) {
|
||||
customHtmlOptions[key] = pageConfig[key]
|
||||
}
|
||||
}
|
||||
|
||||
// inject entry
|
||||
const entries = Array.isArray(entry) ? entry : [entry]
|
||||
webpackConfig.entry(name).merge(entries.map(e => api.resolve(e)))
|
||||
|
||||
// trim inline loader
|
||||
// * See https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md#2-setting-a-loader-directly-for-the-template
|
||||
const templateWithoutLoader = template.replace(/^.+!/, '').replace(/\?.+$/, '')
|
||||
|
||||
// resolve page index template
|
||||
const hasDedicatedTemplate = fs.existsSync(api.resolve(templateWithoutLoader))
|
||||
const templatePath = hasDedicatedTemplate
|
||||
? template
|
||||
: fs.existsSync(htmlPath)
|
||||
? htmlPath
|
||||
: defaultHtmlPath
|
||||
|
||||
publicCopyIgnore.push(api.resolve(templateWithoutLoader).replace(/\\/g, '/'))
|
||||
|
||||
// inject html plugin for the page
|
||||
const pageHtmlOptions = Object.assign(
|
||||
{},
|
||||
htmlOptions,
|
||||
{
|
||||
chunks,
|
||||
template: templatePath,
|
||||
filename: ensureRelative(outputDir, filename)
|
||||
},
|
||||
customHtmlOptions
|
||||
)
|
||||
|
||||
webpackConfig
|
||||
.plugin(`html-${name}`)
|
||||
.use(HTMLPlugin, [pageHtmlOptions])
|
||||
})
|
||||
|
||||
// FIXME: preload plugin is not compatible with webpack 5 / html-webpack-plugin 4 yet
|
||||
// if (!isLegacyBundle) {
|
||||
// pages.forEach(name => {
|
||||
// const filename = ensureRelative(
|
||||
// outputDir,
|
||||
// normalizePageConfig(multiPageConfig[name]).filename || `${name}.html`
|
||||
// )
|
||||
// webpackConfig
|
||||
// .plugin(`preload-${name}`)
|
||||
// .use(PreloadPlugin, [{
|
||||
// rel: 'preload',
|
||||
// includeHtmlNames: [filename],
|
||||
// include: {
|
||||
// type: 'initial',
|
||||
// entries: [name]
|
||||
// },
|
||||
// fileBlacklist: [/\.map$/, /hot-update\.js$/]
|
||||
// }])
|
||||
|
||||
// webpackConfig
|
||||
// .plugin(`prefetch-${name}`)
|
||||
// .use(PreloadPlugin, [{
|
||||
// rel: 'prefetch',
|
||||
// includeHtmlNames: [filename],
|
||||
// include: {
|
||||
// type: 'asyncChunks',
|
||||
// entries: [name]
|
||||
// }
|
||||
// }])
|
||||
// })
|
||||
// }
|
||||
}
|
||||
|
||||
// CORS and Subresource Integrity
|
||||
if (options.crossorigin != null || options.integrity) {
|
||||
webpackConfig
|
||||
.plugin('cors')
|
||||
.use(require('../webpack/CorsPlugin'), [{
|
||||
crossorigin: options.crossorigin,
|
||||
integrity: options.integrity,
|
||||
publicPath: options.publicPath
|
||||
}])
|
||||
}
|
||||
|
||||
// copy static assets in public/
|
||||
const publicDir = api.resolve('public')
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
const PlaceholderPlugin = class PlaceholderPlugin { apply () {} }
|
||||
|
||||
const copyOptions = {
|
||||
patterns: [{
|
||||
from: publicDir,
|
||||
to: outputDir,
|
||||
toType: 'dir',
|
||||
noErrorOnMissing: true,
|
||||
globOptions: {
|
||||
ignore: publicCopyIgnore
|
||||
},
|
||||
info: {
|
||||
minimized: true
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
if (fs.existsSync(publicDir)) {
|
||||
if (isLegacyBundle) {
|
||||
webpackConfig.plugin('copy').use(PlaceholderPlugin, [copyOptions])
|
||||
} else {
|
||||
webpackConfig.plugin('copy').use(CopyWebpackPlugin, [copyOptions])
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
47
app_vue/node_modules/@vue/cli-service/lib/config/assets.js
generated
vendored
Normal file
47
app_vue/node_modules/@vue/cli-service/lib/config/assets.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/** @type {import('@vue/cli-service').ServicePlugin} */
|
||||
module.exports = (api, options) => {
|
||||
const getAssetPath = require('../util/getAssetPath')
|
||||
|
||||
const genAssetSubPath = dir => {
|
||||
return getAssetPath(
|
||||
options,
|
||||
`${dir}/[name]${options.filenameHashing ? '.[hash:8]' : ''}[ext]`
|
||||
)
|
||||
}
|
||||
|
||||
api.chainWebpack(webpackConfig => {
|
||||
webpackConfig.module
|
||||
.rule('svg')
|
||||
.test(/\.(svg)(\?.*)?$/)
|
||||
// do not base64-inline SVGs.
|
||||
// https://github.com/facebookincubator/create-react-app/pull/1180
|
||||
.set('type', 'asset/resource')
|
||||
.set('generator', {
|
||||
filename: genAssetSubPath('img')
|
||||
})
|
||||
|
||||
webpackConfig.module
|
||||
.rule('images')
|
||||
.test(/\.(png|jpe?g|gif|webp|avif)(\?.*)?$/)
|
||||
.set('type', 'asset')
|
||||
.set('generator', {
|
||||
filename: genAssetSubPath('img')
|
||||
})
|
||||
|
||||
webpackConfig.module
|
||||
.rule('media')
|
||||
.test(/\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/)
|
||||
.set('type', 'asset')
|
||||
.set('generator', {
|
||||
filename: genAssetSubPath('media')
|
||||
})
|
||||
|
||||
webpackConfig.module
|
||||
.rule('fonts')
|
||||
.test(/\.(woff2?|eot|ttf|otf)(\?.*)?$/i)
|
||||
.set('type', 'asset')
|
||||
.set('generator', {
|
||||
filename: genAssetSubPath('fonts')
|
||||
})
|
||||
})
|
||||
}
|
226
app_vue/node_modules/@vue/cli-service/lib/config/base.js
generated
vendored
Normal file
226
app_vue/node_modules/@vue/cli-service/lib/config/base.js
generated
vendored
Normal file
@ -0,0 +1,226 @@
|
||||
const path = require('path')
|
||||
|
||||
/** @type {import('@vue/cli-service').ServicePlugin} */
|
||||
module.exports = (api, options) => {
|
||||
const cwd = api.getCwd()
|
||||
const webpack = require('webpack')
|
||||
const vueMajor = require('../util/getVueMajor')(cwd)
|
||||
|
||||
api.chainWebpack(webpackConfig => {
|
||||
const isLegacyBundle = process.env.VUE_CLI_MODERN_MODE && !process.env.VUE_CLI_MODERN_BUILD
|
||||
const resolveLocal = require('../util/resolveLocal')
|
||||
|
||||
// https://github.com/webpack/webpack/issues/14532#issuecomment-947525539
|
||||
webpackConfig.output.set('hashFunction', 'xxhash64')
|
||||
|
||||
// https://github.com/webpack/webpack/issues/11467#issuecomment-691873586
|
||||
webpackConfig.module
|
||||
.rule('esm')
|
||||
.test(/\.m?jsx?$/)
|
||||
.resolve.set('fullySpecified', false)
|
||||
|
||||
webpackConfig
|
||||
.mode('development')
|
||||
.context(api.service.context)
|
||||
.entry('app')
|
||||
.add('./src/main.js')
|
||||
.end()
|
||||
.output
|
||||
.path(api.resolve(options.outputDir))
|
||||
.filename(isLegacyBundle ? '[name]-legacy.js' : '[name].js')
|
||||
.publicPath(options.publicPath)
|
||||
|
||||
webpackConfig.resolve
|
||||
.extensions
|
||||
.merge(['.mjs', '.js', '.jsx', '.vue', '.json', '.wasm'])
|
||||
.end()
|
||||
.modules
|
||||
.add('node_modules')
|
||||
.add(api.resolve('node_modules'))
|
||||
.add(resolveLocal('node_modules'))
|
||||
.end()
|
||||
.alias
|
||||
.set('@', api.resolve('src'))
|
||||
|
||||
webpackConfig.resolveLoader
|
||||
.modules
|
||||
.add('node_modules')
|
||||
.add(api.resolve('node_modules'))
|
||||
.add(resolveLocal('node_modules'))
|
||||
|
||||
webpackConfig.module
|
||||
.noParse(/^(vue|vue-router|vuex|vuex-router-sync)$/)
|
||||
|
||||
// js is handled by cli-plugin-babel ---------------------------------------
|
||||
|
||||
// vue-loader --------------------------------------------------------------
|
||||
let cacheLoaderPath
|
||||
try {
|
||||
cacheLoaderPath = require.resolve('cache-loader')
|
||||
} catch (e) {}
|
||||
|
||||
if (vueMajor === 2) {
|
||||
// for Vue 2 projects
|
||||
const partialIdentifier = {
|
||||
'vue-loader': require('@vue/vue-loader-v15/package.json').version,
|
||||
'@vue/component-compiler-utils': require('@vue/component-compiler-utils/package.json').version
|
||||
}
|
||||
|
||||
try {
|
||||
partialIdentifier['vue-template-compiler'] = require('vue-template-compiler/package.json').version
|
||||
} catch (e) {
|
||||
// For Vue 2.7 projects, `vue-template-compiler` is not required
|
||||
}
|
||||
|
||||
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', partialIdentifier)
|
||||
|
||||
webpackConfig.resolve
|
||||
.alias
|
||||
.set(
|
||||
'vue$',
|
||||
options.runtimeCompiler
|
||||
? 'vue/dist/vue.esm.js'
|
||||
: 'vue/dist/vue.runtime.esm.js'
|
||||
)
|
||||
|
||||
if (cacheLoaderPath) {
|
||||
webpackConfig.module
|
||||
.rule('vue')
|
||||
.test(/\.vue$/)
|
||||
.use('cache-loader')
|
||||
.loader(cacheLoaderPath)
|
||||
.options(vueLoaderCacheConfig)
|
||||
}
|
||||
|
||||
webpackConfig.module
|
||||
.rule('vue')
|
||||
.test(/\.vue$/)
|
||||
.use('vue-loader')
|
||||
.loader(require.resolve('@vue/vue-loader-v15'))
|
||||
.options(Object.assign({
|
||||
compilerOptions: {
|
||||
whitespace: 'condense'
|
||||
}
|
||||
}, cacheLoaderPath ? vueLoaderCacheConfig : {}))
|
||||
|
||||
webpackConfig
|
||||
.plugin('vue-loader')
|
||||
.use(require('@vue/vue-loader-v15').VueLoaderPlugin)
|
||||
|
||||
// some plugins may implicitly relies on the `vue-loader` dependency path name
|
||||
// such as vue-cli-plugin-apollo
|
||||
// <https://github.com/Akryum/vue-cli-plugin-apollo/blob/d9fe48c61cc19db88fef4e4aa5e49b31aa0c44b7/index.js#L88>
|
||||
// so we need a hotfix for that
|
||||
webpackConfig
|
||||
.resolveLoader
|
||||
.modules
|
||||
.prepend(path.resolve(__dirname, './vue-loader-v15-resolve-compat'))
|
||||
} else if (vueMajor === 3) {
|
||||
// for Vue 3 projects
|
||||
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
|
||||
'vue-loader': require('vue-loader/package.json').version
|
||||
})
|
||||
|
||||
webpackConfig.resolve
|
||||
.alias
|
||||
.set(
|
||||
'vue$',
|
||||
options.runtimeCompiler
|
||||
? 'vue/dist/vue.esm-bundler.js'
|
||||
: 'vue/dist/vue.runtime.esm-bundler.js'
|
||||
)
|
||||
|
||||
if (cacheLoaderPath) {
|
||||
webpackConfig.module
|
||||
.rule('vue')
|
||||
.test(/\.vue$/)
|
||||
.use('cache-loader')
|
||||
.loader(cacheLoaderPath)
|
||||
.options(vueLoaderCacheConfig)
|
||||
}
|
||||
|
||||
webpackConfig.module
|
||||
.rule('vue')
|
||||
.test(/\.vue$/)
|
||||
.use('vue-loader')
|
||||
.loader(require.resolve('vue-loader'))
|
||||
.options({
|
||||
...vueLoaderCacheConfig,
|
||||
babelParserPlugins: ['jsx', 'classProperties', 'decorators-legacy']
|
||||
})
|
||||
|
||||
webpackConfig
|
||||
.plugin('vue-loader')
|
||||
.use(require('vue-loader').VueLoaderPlugin)
|
||||
|
||||
// feature flags <http://link.vuejs.org/feature-flags>
|
||||
webpackConfig
|
||||
.plugin('feature-flags')
|
||||
.use(webpack.DefinePlugin, [{
|
||||
__VUE_OPTIONS_API__: 'true',
|
||||
__VUE_PROD_DEVTOOLS__: 'false'
|
||||
}])
|
||||
}
|
||||
|
||||
// https://github.com/vuejs/vue-loader/issues/1435#issuecomment-869074949
|
||||
webpackConfig.module
|
||||
.rule('vue-style')
|
||||
.test(/\.vue$/)
|
||||
.resourceQuery(/type=style/)
|
||||
.sideEffects(true)
|
||||
|
||||
// Other common pre-processors ---------------------------------------------
|
||||
const maybeResolve = name => {
|
||||
try {
|
||||
return require.resolve(name)
|
||||
} catch (error) {
|
||||
return name
|
||||
}
|
||||
}
|
||||
|
||||
webpackConfig.module
|
||||
.rule('pug')
|
||||
.test(/\.pug$/)
|
||||
.oneOf('pug-vue')
|
||||
.resourceQuery(/vue/)
|
||||
.use('pug-plain-loader')
|
||||
.loader(maybeResolve('pug-plain-loader'))
|
||||
.end()
|
||||
.end()
|
||||
.oneOf('pug-template')
|
||||
.use('raw')
|
||||
.loader(maybeResolve('raw-loader'))
|
||||
.end()
|
||||
.use('pug-plain-loader')
|
||||
.loader(maybeResolve('pug-plain-loader'))
|
||||
.end()
|
||||
.end()
|
||||
|
||||
const resolveClientEnv = require('../util/resolveClientEnv')
|
||||
webpackConfig
|
||||
.plugin('define')
|
||||
.use(webpack.DefinePlugin, [
|
||||
resolveClientEnv(options)
|
||||
])
|
||||
|
||||
webpackConfig
|
||||
.plugin('case-sensitive-paths')
|
||||
.use(require('case-sensitive-paths-webpack-plugin'))
|
||||
|
||||
// friendly error plugin displays very confusing errors when webpack
|
||||
// fails to resolve a loader, so we provide custom handlers to improve it
|
||||
const { transformer, formatter } = require('../util/resolveLoaderError')
|
||||
webpackConfig
|
||||
.plugin('friendly-errors')
|
||||
.use(require('@soda/friendly-errors-webpack-plugin'), [{
|
||||
additionalTransformers: [transformer],
|
||||
additionalFormatters: [formatter]
|
||||
}])
|
||||
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
const terserOptions = require('./terserOptions')
|
||||
webpackConfig.optimization
|
||||
.minimizer('terser')
|
||||
.use(TerserPlugin, [terserOptions(options)])
|
||||
})
|
||||
}
|
234
app_vue/node_modules/@vue/cli-service/lib/config/css.js
generated
vendored
Normal file
234
app_vue/node_modules/@vue/cli-service/lib/config/css.js
generated
vendored
Normal file
@ -0,0 +1,234 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { chalk, semver, loadModule } = require('@vue/cli-shared-utils')
|
||||
const isAbsoluteUrl = require('../util/isAbsoluteUrl')
|
||||
|
||||
const findExisting = (context, files) => {
|
||||
for (const file of files) {
|
||||
if (fs.existsSync(path.join(context, file))) {
|
||||
return file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (api, rootOptions) => {
|
||||
api.chainWebpack(webpackConfig => {
|
||||
const getAssetPath = require('../util/getAssetPath')
|
||||
const shadowMode = !!process.env.VUE_CLI_CSS_SHADOW_MODE
|
||||
const isProd = process.env.NODE_ENV === 'production'
|
||||
|
||||
const {
|
||||
extract = isProd,
|
||||
sourceMap = false,
|
||||
loaderOptions = {}
|
||||
} = rootOptions.css || {}
|
||||
|
||||
const shouldExtract = extract !== false && !shadowMode
|
||||
const filename = getAssetPath(
|
||||
rootOptions,
|
||||
`css/[name]${rootOptions.filenameHashing ? '.[contenthash:8]' : ''}.css`
|
||||
)
|
||||
const extractOptions = Object.assign({
|
||||
filename,
|
||||
chunkFilename: filename
|
||||
}, extract && typeof extract === 'object' ? extract : {})
|
||||
|
||||
// when project publicPath is a relative path
|
||||
// use relative publicPath in extracted CSS based on extract location
|
||||
const cssPublicPath = (isAbsoluteUrl(rootOptions.publicPath) || rootOptions.publicPath.startsWith('/'))
|
||||
? rootOptions.publicPath
|
||||
: process.env.VUE_CLI_BUILD_TARGET === 'lib'
|
||||
// in lib mode, CSS is extracted to dist root.
|
||||
? './'
|
||||
: '../'.repeat(
|
||||
extractOptions.filename
|
||||
.replace(/^\.[/\\]/, '')
|
||||
.split(/[/\\]/g)
|
||||
.length - 1
|
||||
)
|
||||
|
||||
// check if the project has a valid postcss config
|
||||
// if it doesn't, don't use postcss-loader for direct style imports
|
||||
// because otherwise it would throw error when attempting to load postcss config
|
||||
const hasPostCSSConfig = !!(loaderOptions.postcss || api.service.pkg.postcss || findExisting(api.resolve('.'), [
|
||||
'.postcssrc',
|
||||
'.postcssrc.js',
|
||||
'postcss.config.js',
|
||||
'.postcssrc.yaml',
|
||||
'.postcssrc.json'
|
||||
]))
|
||||
|
||||
if (!hasPostCSSConfig) {
|
||||
// #6342
|
||||
// NPM 6 may incorrectly hoist postcss 7 to the same level of autoprefixer
|
||||
// So we have to run a preflight check to tell the users how to fix it
|
||||
const autoprefixerDirectory = path.dirname(require.resolve('autoprefixer/package.json'))
|
||||
const postcssPkg = loadModule('postcss/package.json', autoprefixerDirectory)
|
||||
const postcssVersion = postcssPkg.version
|
||||
if (!semver.satisfies(postcssVersion, '8.x')) {
|
||||
throw new Error(
|
||||
`The package manager has hoisted a wrong version of ${chalk.cyan('postcss')}, ` +
|
||||
`please run ${chalk.cyan('npm i postcss@8 -D')} to fix it.`
|
||||
)
|
||||
}
|
||||
|
||||
loaderOptions.postcss = {
|
||||
postcssOptions: {
|
||||
plugins: [
|
||||
require('autoprefixer')
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if building for production but not extracting CSS, we need to minimize
|
||||
// the embbeded inline CSS as they will not be going through the optimizing
|
||||
// plugin.
|
||||
const needInlineMinification = isProd && !shouldExtract
|
||||
|
||||
const cssnanoOptions = {
|
||||
preset: ['default', {
|
||||
mergeLonghand: false,
|
||||
cssDeclarationSorter: false
|
||||
}]
|
||||
}
|
||||
if (rootOptions.productionSourceMap && sourceMap) {
|
||||
cssnanoOptions.map = { inline: false }
|
||||
}
|
||||
|
||||
function createCSSRule (lang, test, loader, options) {
|
||||
const baseRule = webpackConfig.module.rule(lang).test(test)
|
||||
|
||||
// rules for <style module>
|
||||
const vueModulesRule = baseRule.oneOf('vue-modules').resourceQuery(/module/)
|
||||
applyLoaders(vueModulesRule, true)
|
||||
|
||||
// rules for <style>
|
||||
const vueNormalRule = baseRule.oneOf('vue').resourceQuery(/\?vue/)
|
||||
applyLoaders(vueNormalRule)
|
||||
|
||||
// rules for *.module.* files
|
||||
const extModulesRule = baseRule.oneOf('normal-modules').test(/\.module\.\w+$/)
|
||||
applyLoaders(extModulesRule)
|
||||
|
||||
// rules for normal CSS imports
|
||||
const normalRule = baseRule.oneOf('normal')
|
||||
applyLoaders(normalRule)
|
||||
|
||||
function applyLoaders (rule, forceCssModule = false) {
|
||||
if (shouldExtract) {
|
||||
rule
|
||||
.use('extract-css-loader')
|
||||
.loader(require('mini-css-extract-plugin').loader)
|
||||
.options({
|
||||
publicPath: cssPublicPath
|
||||
})
|
||||
} else {
|
||||
rule
|
||||
.use('vue-style-loader')
|
||||
.loader(require.resolve('vue-style-loader'))
|
||||
.options({
|
||||
sourceMap,
|
||||
shadowMode
|
||||
})
|
||||
}
|
||||
|
||||
const cssLoaderOptions = Object.assign({
|
||||
sourceMap,
|
||||
importLoaders: (
|
||||
1 + // stylePostLoader injected by vue-loader
|
||||
1 + // postcss-loader
|
||||
(needInlineMinification ? 1 : 0)
|
||||
)
|
||||
}, loaderOptions.css)
|
||||
|
||||
if (forceCssModule) {
|
||||
cssLoaderOptions.modules = {
|
||||
...cssLoaderOptions.modules,
|
||||
auto: () => true
|
||||
}
|
||||
}
|
||||
|
||||
if (cssLoaderOptions.modules) {
|
||||
cssLoaderOptions.modules = {
|
||||
localIdentName: '[name]_[local]_[hash:base64:5]',
|
||||
...cssLoaderOptions.modules
|
||||
}
|
||||
}
|
||||
|
||||
rule
|
||||
.use('css-loader')
|
||||
.loader(require.resolve('css-loader'))
|
||||
.options(cssLoaderOptions)
|
||||
|
||||
if (needInlineMinification) {
|
||||
rule
|
||||
.use('cssnano')
|
||||
.loader(require.resolve('postcss-loader'))
|
||||
.options({
|
||||
sourceMap,
|
||||
postcssOptions: {
|
||||
plugins: [require('cssnano')(cssnanoOptions)]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
rule
|
||||
.use('postcss-loader')
|
||||
.loader(require.resolve('postcss-loader'))
|
||||
.options(Object.assign({ sourceMap }, loaderOptions.postcss))
|
||||
|
||||
if (loader) {
|
||||
let resolvedLoader
|
||||
try {
|
||||
resolvedLoader = require.resolve(loader)
|
||||
} catch (error) {
|
||||
resolvedLoader = loader
|
||||
}
|
||||
|
||||
rule
|
||||
.use(loader)
|
||||
.loader(resolvedLoader)
|
||||
.options(Object.assign({ sourceMap }, options))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
createCSSRule('css', /\.css$/)
|
||||
createCSSRule('postcss', /\.p(ost)?css$/)
|
||||
createCSSRule('scss', /\.scss$/, 'sass-loader', Object.assign(
|
||||
{},
|
||||
loaderOptions.scss || loaderOptions.sass
|
||||
))
|
||||
createCSSRule('sass', /\.sass$/, 'sass-loader', Object.assign(
|
||||
{},
|
||||
loaderOptions.sass,
|
||||
{
|
||||
sassOptions: Object.assign(
|
||||
{},
|
||||
loaderOptions.sass && loaderOptions.sass.sassOptions,
|
||||
{
|
||||
indentedSyntax: true
|
||||
}
|
||||
)
|
||||
}
|
||||
))
|
||||
createCSSRule('less', /\.less$/, 'less-loader', loaderOptions.less)
|
||||
createCSSRule('stylus', /\.styl(us)?$/, 'stylus-loader', loaderOptions.stylus)
|
||||
|
||||
// inject CSS extraction plugin
|
||||
if (shouldExtract) {
|
||||
webpackConfig
|
||||
.plugin('extract-css')
|
||||
.use(require('mini-css-extract-plugin'), [extractOptions])
|
||||
|
||||
// minify extracted CSS
|
||||
webpackConfig.optimization
|
||||
.minimizer('css')
|
||||
.use(require('css-minimizer-webpack-plugin'), [{
|
||||
parallel: rootOptions.parallel,
|
||||
minimizerOptions: cssnanoOptions
|
||||
}])
|
||||
}
|
||||
})
|
||||
}
|
12
app_vue/node_modules/@vue/cli-service/lib/config/index-default.html
generated
vendored
Normal file
12
app_vue/node_modules/@vue/cli-service/lib/config/index-default.html
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<title>Vue App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
15
app_vue/node_modules/@vue/cli-service/lib/config/prod.js
generated
vendored
Normal file
15
app_vue/node_modules/@vue/cli-service/lib/config/prod.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/** @type {import('@vue/cli-service').ServicePlugin} */
|
||||
module.exports = (api, options) => {
|
||||
api.chainWebpack(webpackConfig => {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
webpackConfig
|
||||
.mode('production')
|
||||
.devtool(options.productionSourceMap ? 'source-map' : false)
|
||||
|
||||
// disable optimization during tests to speed things up
|
||||
if (process.env.VUE_CLI_TEST && !process.env.VUE_CLI_TEST_MINIMIZE) {
|
||||
webpackConfig.optimization.minimize(false)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
110
app_vue/node_modules/@vue/cli-service/lib/config/terserOptions.js
generated
vendored
Normal file
110
app_vue/node_modules/@vue/cli-service/lib/config/terserOptions.js
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
// @ts-check
|
||||
const TerserPlugin = require('terser-webpack-plugin')
|
||||
|
||||
const genTerserOptions = (defaultOptions, options) => {
|
||||
const userOptions = options.terser && options.terser.terserOptions
|
||||
// user's config is first
|
||||
return {
|
||||
...defaultOptions,
|
||||
...userOptions
|
||||
}
|
||||
}
|
||||
|
||||
const terserMinify = (options) => ({
|
||||
terserOptions: genTerserOptions(
|
||||
{
|
||||
compress: {
|
||||
// turn off flags with small gains to speed up minification
|
||||
arrows: false,
|
||||
collapse_vars: false, // 0.3kb
|
||||
comparisons: false,
|
||||
computed_props: false,
|
||||
hoist_funs: false,
|
||||
hoist_props: false,
|
||||
hoist_vars: false,
|
||||
inline: false,
|
||||
loops: false,
|
||||
negate_iife: false,
|
||||
properties: false,
|
||||
reduce_funcs: false,
|
||||
reduce_vars: false,
|
||||
switches: false,
|
||||
toplevel: false,
|
||||
typeofs: false,
|
||||
|
||||
// a few flags with noticeable gains/speed ratio
|
||||
// numbers based on out of the box vendor bundle
|
||||
booleans: true, // 0.7kb
|
||||
if_return: true, // 0.4kb
|
||||
sequences: true, // 0.7kb
|
||||
unused: true, // 2.3kb
|
||||
|
||||
// required features to drop conditional branches
|
||||
conditionals: true,
|
||||
dead_code: true,
|
||||
evaluate: true
|
||||
},
|
||||
mangle: {
|
||||
safari10: true
|
||||
}
|
||||
},
|
||||
options
|
||||
),
|
||||
parallel: options.parallel,
|
||||
extractComments: false
|
||||
})
|
||||
|
||||
// `terserOptions` options will be passed to `esbuild`
|
||||
// Link to options - https://esbuild.github.io/api/#minify
|
||||
const esbuildMinify = (options) => ({
|
||||
minify: TerserPlugin.esbuildMinify,
|
||||
terserOptions: genTerserOptions(
|
||||
{
|
||||
minify: false,
|
||||
minifyWhitespace: true,
|
||||
minifyIdentifiers: false,
|
||||
minifySyntax: true
|
||||
},
|
||||
options
|
||||
),
|
||||
parallel: options.parallel
|
||||
})
|
||||
|
||||
// `terserOptions` options will be passed to `swc` (`@swc/core`)
|
||||
// Link to options - https://swc.rs/docs/config-js-minify
|
||||
const swcMinify = (options) => ({
|
||||
minify: TerserPlugin.swcMinify,
|
||||
terserOptions: genTerserOptions(
|
||||
{
|
||||
compress: {
|
||||
unused: true
|
||||
},
|
||||
mangle: true
|
||||
},
|
||||
options
|
||||
),
|
||||
parallel: options.parallel
|
||||
})
|
||||
|
||||
// `terserOptions` options will be passed to `uglify-js`
|
||||
// Link to options - https://github.com/mishoo/UglifyJS#minify-options
|
||||
const uglifyJsMinify = (options) => ({
|
||||
minify: TerserPlugin.uglifyJsMinify,
|
||||
terserOptions: genTerserOptions({}, options),
|
||||
parallel: options.parallel
|
||||
})
|
||||
|
||||
// Currently we do not allow custom minify function
|
||||
const getMinify = (options) => {
|
||||
const { minify = 'terser' } = options.terser || {}
|
||||
|
||||
const minifyMap = {
|
||||
terser: terserMinify,
|
||||
esbuild: esbuildMinify,
|
||||
swc: swcMinify,
|
||||
uglifyJs: uglifyJsMinify
|
||||
}
|
||||
return minifyMap[minify](options)
|
||||
}
|
||||
|
||||
module.exports = getMinify
|
1
app_vue/node_modules/@vue/cli-service/lib/config/vue-loader-v15-resolve-compat/vue-loader.js
generated
vendored
Normal file
1
app_vue/node_modules/@vue/cli-service/lib/config/vue-loader-v15-resolve-compat/vue-loader.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
module.exports = require('@vue/vue-loader-v15')
|
Reference in New Issue
Block a user