@sanpjs/core
Version:
@sanpjs/core
143 lines • 3.71 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const server = {
host: '0.0.0.0',
port: 8888,
https: false,
proxy: {},
hot: true,
mock: '',
allowedHosts: 'all',
static: {},
client: {
logging: 'none',
overlay: { warnings: false, errors: true },
progress: true
},
open: false,
setupExitSignals: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, Content-Type, Authorization'
},
devMiddleware: {
mfs: true
},
finalize: (config) => config
};
const terser = {
format: {
comments: false
},
compress: {
unused: true,
// 删掉 debugger
drop_debugger: true,
// 移除 console
drop_console: true,
// 移除无用的代码
dead_code: true // eslint-disable-line
},
ie8: false,
safari10: true,
warnings: false,
toplevel: true
};
const htmlMinify = {
caseSensitive: true,
removeComments: true,
collapseWhitespace: false,
// 引号保留,不然 inline 的 base64 图片 compress 时报错
removeAttributeQuotes: false,
quoteCharacter: '"',
collapseBooleanAttributes: false,
removeScriptTypeAttributes: false,
minifyCSS: false,
minifyJS: false,
// 处理 smarty 和 php 情况
ignoreCustomFragments: [/{%[\s\S]*?%}/, /<%[\s\S]*?%>/, /<\?[\s\S]*?\?>/],
keepClosingSlash: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
};
const cssnano = {
mergeLonghand: false,
cssDeclarationSorter: false,
normalizeUrl: false,
discardUnused: false,
// 避免 cssnano 重新计算 z-index
zindex: false,
reduceIdents: false,
safe: true,
// cssnano 集成了 autoprefixer 的功能
// 会使用到 autoprefixer 进行无关前缀的清理
// 关闭 autoprefixer 功能
// 使用 postcss 的 autoprefixer 功能
autoprefixer: false,
discardComments: {
removeAll: true
}
};
exports.default = {
root: process.cwd(),
// type: spa含有前端路由的单页应用,mpa多入口单文件应用,ssr服务端渲染
type: 'spa',
pagesDir: 'pages',
// sanp生成的文件目录
sanpDir: '.sanp',
attachedElement: '#app',
// mode development production
mode: 'development',
// 插件
plugins: [],
// 页面配置
pages: undefined,
// 构建进度
progress: true,
// 监听模式
watch: false,
// build
build: {
copy: undefined,
outDir: 'output',
analyze: false,
clean: false,
sourceMap: false,
publicPath: '/',
assetDir: 'static',
hash: false,
largeAssetSize: 1024,
cache: {
type: 'filesystem',
allowCollectingMemory: true
},
parallel: false,
esModule: false,
esbuild: false,
// 检查代码,比如检查出现额外的依赖、检查最后代码是不是es5
inspect: undefined,
// script
script: {
babel: {},
polyfills: '',
finalize: (config) => config
},
// style
style: {
extract: true,
modules: undefined
},
optimization: {
splitChunks: {},
terser,
cssnano,
htmlMinify
},
finalize: (config) => config
},
server,
// ssr预留
ssr: {}
};
//# sourceMappingURL=defaultOptions.js.map