mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
chore(cli): update eslint config and prettier codes
This commit is contained in:
@@ -23,7 +23,7 @@ import {
|
||||
isDemoDir,
|
||||
isTestDir,
|
||||
setNodeEnv,
|
||||
setModuleEnv
|
||||
setModuleEnv,
|
||||
} from '../common';
|
||||
|
||||
async function compileFile(filePath: string) {
|
||||
@@ -62,7 +62,6 @@ async function compileDir(dir: string) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
async function buildEs() {
|
||||
setModuleEnv('esmodule');
|
||||
await copy(SRC_DIR, ES_DIR);
|
||||
@@ -87,7 +86,7 @@ async function buildPacakgeEntry() {
|
||||
|
||||
genPackageEntry({
|
||||
outputPath: esEntryFile,
|
||||
pathResolver: (path: string) => `./${relative(SRC_DIR, path)}`
|
||||
pathResolver: (path: string) => `./${relative(SRC_DIR, path)}`,
|
||||
});
|
||||
|
||||
setModuleEnv('esmodule');
|
||||
@@ -95,7 +94,7 @@ async function buildPacakgeEntry() {
|
||||
|
||||
genPacakgeStyle({
|
||||
outputPath: styleEntryFile,
|
||||
pathResolver: (path: string) => path.replace(SRC_DIR, '.')
|
||||
pathResolver: (path: string) => path.replace(SRC_DIR, '.'),
|
||||
});
|
||||
|
||||
setModuleEnv('commonjs');
|
||||
@@ -114,24 +113,24 @@ async function buildPackages() {
|
||||
const tasks = [
|
||||
{
|
||||
text: 'Build ESModule Outputs',
|
||||
task: buildEs
|
||||
task: buildEs,
|
||||
},
|
||||
{
|
||||
text: 'Build Commonjs Outputs',
|
||||
task: buildLib
|
||||
task: buildLib,
|
||||
},
|
||||
{
|
||||
text: 'Build Style Entry',
|
||||
task: buildStyleEntry
|
||||
task: buildStyleEntry,
|
||||
},
|
||||
{
|
||||
text: 'Build Package Entry',
|
||||
task: buildPacakgeEntry
|
||||
task: buildPacakgeEntry,
|
||||
},
|
||||
{
|
||||
text: 'Build Packed Outputs',
|
||||
task: buildPackages
|
||||
}
|
||||
task: buildPackages,
|
||||
},
|
||||
];
|
||||
|
||||
async function runBuildTasks() {
|
||||
|
@@ -19,7 +19,7 @@ function formatType(type: string) {
|
||||
fix: 'Bug Fixes',
|
||||
feat: 'Feature',
|
||||
docs: 'Document',
|
||||
types: 'Types'
|
||||
types: 'Types',
|
||||
};
|
||||
|
||||
return MAP[type] || type;
|
||||
@@ -52,7 +52,7 @@ export async function changelog() {
|
||||
return new Promise(resolve => {
|
||||
conventionalChangelog(
|
||||
{
|
||||
preset: 'angular'
|
||||
preset: 'angular',
|
||||
},
|
||||
null,
|
||||
null,
|
||||
@@ -61,7 +61,7 @@ export async function changelog() {
|
||||
mainTemplate,
|
||||
headerPartial,
|
||||
commitPartial,
|
||||
transform
|
||||
transform,
|
||||
}
|
||||
)
|
||||
.pipe(createWriteStream(DIST_FILE))
|
||||
|
@@ -6,6 +6,6 @@ export async function clean() {
|
||||
emptyDir(ES_DIR),
|
||||
emptyDir(LIB_DIR),
|
||||
emptyDir(DIST_DIR),
|
||||
emptyDir(SITE_DIST_DIR)
|
||||
emptyDir(SITE_DIST_DIR),
|
||||
]);
|
||||
}
|
||||
|
@@ -7,14 +7,14 @@ export function test(command: any) {
|
||||
setNodeEnv('test');
|
||||
|
||||
genPackageEntry({
|
||||
outputPath: PACKAGE_ENTRY_FILE
|
||||
outputPath: PACKAGE_ENTRY_FILE,
|
||||
});
|
||||
|
||||
const config = {
|
||||
rootDir: ROOT,
|
||||
watch: command.watch,
|
||||
config: JEST_CONFIG_FILE,
|
||||
clearCache: command.clearCache
|
||||
clearCache: command.clearCache,
|
||||
} as any;
|
||||
|
||||
runCLI(config, [ROOT])
|
||||
|
@@ -18,7 +18,7 @@ function runCommand(
|
||||
|
||||
return new Promise(resolve => {
|
||||
execa(cmd, options, {
|
||||
env: { FORCE_COLOR: true }
|
||||
env: { FORCE_COLOR: true },
|
||||
})
|
||||
.then(() => {
|
||||
spinner.succeed(messages.succeed);
|
||||
@@ -39,7 +39,7 @@ function eslint() {
|
||||
{
|
||||
start: 'Running eslint...',
|
||||
succeed: 'ESLint Passed.',
|
||||
failed: 'ESLint failed!'
|
||||
failed: 'ESLint failed!',
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ function stylelint() {
|
||||
{
|
||||
start: 'Running stylelint...',
|
||||
succeed: 'Stylelint Passed.',
|
||||
failed: 'Stylelint failed!'
|
||||
failed: 'Stylelint failed!',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -8,11 +8,11 @@ const PLUGIN_PATH = join(__dirname, '../compiler/vant-cli-release-plugin.js');
|
||||
export async function release() {
|
||||
await releaseIt({
|
||||
plugins: {
|
||||
[PLUGIN_PATH]: {}
|
||||
[PLUGIN_PATH]: {},
|
||||
},
|
||||
git: {
|
||||
tagName: 'v${version}',
|
||||
commitMessage: 'chore: release ${version}'
|
||||
}
|
||||
commitMessage: 'chore: release ${version}',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@@ -4,13 +4,13 @@ import {
|
||||
existsSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
outputFileSync
|
||||
outputFileSync,
|
||||
} from 'fs-extra';
|
||||
import {
|
||||
SRC_DIR,
|
||||
getVantConfig,
|
||||
ROOT_WEBPACK_CONFIG_FILE,
|
||||
ROOT_POSTCSS_CONFIG_FILE
|
||||
ROOT_POSTCSS_CONFIG_FILE,
|
||||
} from './constant';
|
||||
|
||||
export const EXT_REGEXP = /\.\w+$/;
|
||||
|
@@ -25,7 +25,7 @@ export async function installDependencies() {
|
||||
const manager = hasYarn() ? 'yarn' : 'npm';
|
||||
|
||||
await execa(manager, ['install', '--prod=false'], {
|
||||
stdio: 'inherit'
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
console.log('');
|
||||
|
@@ -8,7 +8,7 @@ const cleanCss = new CleanCss();
|
||||
export async function compileCss(source: string | Buffer) {
|
||||
const config = await postcssrc({}, POSTCSS_CONFIG_FILE);
|
||||
const { css } = await postcss(config.plugins as any).process(source, {
|
||||
from: undefined
|
||||
from: undefined,
|
||||
});
|
||||
|
||||
return cleanCss.minify(css).styles;
|
||||
|
@@ -13,14 +13,14 @@ class TildeResolver extends FileManager {
|
||||
const TildeResolverPlugin = {
|
||||
install(lessInstance: unknown, pluginManager: any) {
|
||||
pluginManager.addFileManager(new TildeResolver());
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export async function compileLess(filePath: string) {
|
||||
const source = readFileSync(filePath, 'utf-8');
|
||||
const { css } = await render(source, {
|
||||
filename: filePath,
|
||||
plugins: [TildeResolverPlugin]
|
||||
plugins: [TildeResolverPlugin],
|
||||
});
|
||||
|
||||
return css;
|
||||
|
@@ -57,7 +57,7 @@ function compileTemplate(template: string) {
|
||||
const result = compileUtils.compileTemplate({
|
||||
compiler,
|
||||
source: template,
|
||||
isProduction: true
|
||||
isProduction: true,
|
||||
} as any);
|
||||
|
||||
return result.code;
|
||||
@@ -73,7 +73,7 @@ export function parseSfc(filePath: string) {
|
||||
const descriptor = compileUtils.parse({
|
||||
source,
|
||||
compiler,
|
||||
needMap: false
|
||||
needMap: false,
|
||||
} as any);
|
||||
|
||||
return descriptor;
|
||||
|
@@ -39,7 +39,7 @@ function watch() {
|
||||
|
||||
getPort(
|
||||
{
|
||||
port: config.devServer!.port
|
||||
port: config.devServer!.port,
|
||||
},
|
||||
(err, port) => {
|
||||
if (err) {
|
||||
|
@@ -11,7 +11,7 @@ import {
|
||||
ES_DIR,
|
||||
SRC_DIR,
|
||||
LIB_DIR,
|
||||
STYPE_DEPS_JSON_FILE
|
||||
STYPE_DEPS_JSON_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
function getDeps(component: string): string[] {
|
||||
@@ -41,12 +41,12 @@ function getRelativePath(component: string, style: string, ext: string) {
|
||||
const OUTPUT_CONFIG = [
|
||||
{
|
||||
dir: ES_DIR,
|
||||
template: (dep: string) => `import '${dep}';`
|
||||
template: (dep: string) => `import '${dep}';`,
|
||||
},
|
||||
{
|
||||
dir: LIB_DIR,
|
||||
template: (dep: string) => `require('${dep}');`
|
||||
}
|
||||
template: (dep: string) => `require('${dep}');`,
|
||||
},
|
||||
];
|
||||
|
||||
function genEntry(params: {
|
||||
@@ -92,7 +92,7 @@ export function genComponentStyle(
|
||||
baseFile,
|
||||
component,
|
||||
filename: 'index.js',
|
||||
ext: '.css'
|
||||
ext: '.css',
|
||||
});
|
||||
|
||||
if (CSS_LANG !== 'css') {
|
||||
@@ -100,7 +100,7 @@ export function genComponentStyle(
|
||||
baseFile,
|
||||
component,
|
||||
filename: CSS_LANG + '.js',
|
||||
ext: '.' + CSS_LANG
|
||||
ext: '.' + CSS_LANG,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@@ -1,6 +1,11 @@
|
||||
import { get } from 'lodash';
|
||||
import { join } from 'path';
|
||||
import { pascalize, getComponents, smartOutputFile, normalizePath } from '../common';
|
||||
import {
|
||||
pascalize,
|
||||
getComponents,
|
||||
smartOutputFile,
|
||||
normalizePath,
|
||||
} from '../common';
|
||||
import { SRC_DIR, getPackageJson, getVantConfig } from '../common/constant';
|
||||
|
||||
type Options = {
|
||||
|
@@ -6,14 +6,14 @@ import {
|
||||
removeExt,
|
||||
getVantConfig,
|
||||
smartOutputFile,
|
||||
normalizePath
|
||||
normalizePath,
|
||||
} from '../common';
|
||||
import {
|
||||
SRC_DIR,
|
||||
DOCS_DIR,
|
||||
getPackageJson,
|
||||
VANT_CONFIG_FILE,
|
||||
SITE_DESKTOP_SHARED_FILE
|
||||
SITE_DESKTOP_SHARED_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
type DocumentItem = {
|
||||
@@ -52,7 +52,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
||||
components.forEach(component => {
|
||||
docs.push({
|
||||
name: formatName(component, lang),
|
||||
path: join(SRC_DIR, component, fileName)
|
||||
path: join(SRC_DIR, component, fileName),
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -60,7 +60,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
||||
components.forEach(component => {
|
||||
docs.push({
|
||||
name: formatName(component),
|
||||
path: join(SRC_DIR, component, 'README.md')
|
||||
path: join(SRC_DIR, component, 'README.md'),
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -69,7 +69,7 @@ function resolveDocuments(components: string[]): DocumentItem[] {
|
||||
const pairs = parse(path).name.split('.');
|
||||
return {
|
||||
name: formatName(pairs[0], pairs[1] || defaultLang),
|
||||
path
|
||||
path,
|
||||
};
|
||||
});
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import {
|
||||
decamelize,
|
||||
getVantConfig,
|
||||
smartOutputFile,
|
||||
normalizePath
|
||||
normalizePath,
|
||||
} from '../common';
|
||||
|
||||
type DemoItem = {
|
||||
@@ -25,7 +25,10 @@ import './package-style';
|
||||
|
||||
function genImports(demos: DemoItem[]) {
|
||||
return demos
|
||||
.map(item => `import ${item.name} from '${removeExt(normalizePath(item.path))}';`)
|
||||
.map(
|
||||
item =>
|
||||
`import ${item.name} from '${removeExt(normalizePath(item.path))}';`
|
||||
)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
@@ -73,7 +76,7 @@ function genCode(components: string[]) {
|
||||
.map(component => ({
|
||||
component,
|
||||
name: pascalize(component),
|
||||
path: join(SRC_DIR, component, 'demo/index.vue')
|
||||
path: join(SRC_DIR, component, 'demo/index.vue'),
|
||||
}))
|
||||
.filter(item => existsSync(item.path));
|
||||
|
||||
|
@@ -14,7 +14,7 @@ export function genVeturConfig() {
|
||||
path: SRC_DIR,
|
||||
test: /zh-CN\.md/,
|
||||
outputDir: join(ROOT, 'vetur'),
|
||||
...options
|
||||
...options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -15,10 +15,10 @@ export async function genSiteEntry() {
|
||||
genStyleDepsMap()
|
||||
.then(() => {
|
||||
genPackageEntry({
|
||||
outputPath: PACKAGE_ENTRY_FILE
|
||||
outputPath: PACKAGE_ENTRY_FILE,
|
||||
});
|
||||
genPacakgeStyle({
|
||||
outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`)
|
||||
outputPath: replaceExt(PACKAGE_STYLE_FILE, `.${CSS_LANG}`),
|
||||
});
|
||||
genSiteMobileShared();
|
||||
genSiteDesktopShared();
|
||||
|
@@ -15,38 +15,38 @@ module.exports = function(api?: ConfigAPI) {
|
||||
'@babel/preset-env',
|
||||
{
|
||||
loose: true,
|
||||
modules: useESModules ? false : 'commonjs'
|
||||
}
|
||||
modules: useESModules ? false : 'commonjs',
|
||||
},
|
||||
],
|
||||
[
|
||||
'@vue/babel-preset-jsx',
|
||||
{
|
||||
functional: false
|
||||
}
|
||||
functional: false,
|
||||
},
|
||||
],
|
||||
'@babel/preset-typescript'
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
plugins: [
|
||||
[
|
||||
'@babel/plugin-transform-runtime',
|
||||
{
|
||||
corejs: false,
|
||||
useESModules
|
||||
}
|
||||
useESModules,
|
||||
},
|
||||
],
|
||||
[
|
||||
'import',
|
||||
{
|
||||
libraryName: 'vant',
|
||||
libraryDirectory: useESModules ? 'es' : 'lib',
|
||||
style: true
|
||||
style: true,
|
||||
},
|
||||
'vant'
|
||||
'vant',
|
||||
],
|
||||
'@babel/plugin-transform-object-assign',
|
||||
'@babel/plugin-proposal-optional-chaining',
|
||||
'@babel/plugin-proposal-nullish-coalescing-operator'
|
||||
]
|
||||
'@babel/plugin-proposal-nullish-coalescing-operator',
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
|
@@ -4,26 +4,26 @@ import {
|
||||
ROOT,
|
||||
JEST_SETUP_FILE,
|
||||
JEST_FILE_MOCK_FILE,
|
||||
JEST_STYLE_MOCK_FILE
|
||||
JEST_STYLE_MOCK_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
moduleNameMapper: {
|
||||
'\\.(css|less|scss)$': JEST_STYLE_MOCK_FILE,
|
||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE
|
||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': JEST_FILE_MOCK_FILE,
|
||||
},
|
||||
setupFilesAfterEnv: [JEST_SETUP_FILE],
|
||||
moduleFileExtensions: ['js', 'jsx', 'vue', 'ts', 'tsx'],
|
||||
transform: {
|
||||
'\\.(vue)$': 'vue-jest',
|
||||
'\\.(js|jsx|ts|tsx)$': 'babel-jest'
|
||||
'\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
||||
},
|
||||
transformIgnorePatterns: ['/node_modules/(?!(@vant/cli))/'],
|
||||
snapshotSerializers: ['jest-serializer-vue'],
|
||||
collectCoverage: true,
|
||||
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx,vue}', '!**/demo/**'],
|
||||
coverageReporters: ['html', 'lcov', 'text-summary'],
|
||||
coverageDirectory: './test/coverage'
|
||||
coverageDirectory: './test/coverage',
|
||||
};
|
||||
|
||||
function readRootConfig() {
|
||||
@@ -38,5 +38,5 @@ function readRootConfig() {
|
||||
|
||||
module.exports = {
|
||||
...DEFAULT_CONFIG,
|
||||
...readRootConfig()
|
||||
...readRootConfig(),
|
||||
};
|
||||
|
@@ -7,20 +7,20 @@ type PostcssConfig = object & {
|
||||
function mergePostcssConfig(config1: PostcssConfig, config2: PostcssConfig) {
|
||||
const plugins = {
|
||||
...config1.plugins,
|
||||
...config2.plugins
|
||||
...config2.plugins,
|
||||
};
|
||||
|
||||
return {
|
||||
...config1,
|
||||
...config2,
|
||||
plugins
|
||||
plugins,
|
||||
};
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
plugins: {
|
||||
autoprefixer: {}
|
||||
}
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = mergePostcssConfig(DEFAULT_CONFIG, getPostcssConfig());
|
||||
|
@@ -6,14 +6,14 @@ import {
|
||||
CACHE_DIR,
|
||||
STYLE_EXTS,
|
||||
SCRIPT_EXTS,
|
||||
POSTCSS_CONFIG_FILE
|
||||
POSTCSS_CONFIG_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
const CACHE_LOADER = {
|
||||
loader: 'cache-loader',
|
||||
options: {
|
||||
cacheDirectory: CACHE_DIR
|
||||
}
|
||||
cacheDirectory: CACHE_DIR,
|
||||
},
|
||||
};
|
||||
|
||||
const CSS_LOADERS = [
|
||||
@@ -23,16 +23,16 @@ const CSS_LOADERS = [
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
config: {
|
||||
path: POSTCSS_CONFIG_FILE
|
||||
}
|
||||
}
|
||||
}
|
||||
path: POSTCSS_CONFIG_FILE,
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const baseConfig = {
|
||||
mode: 'development',
|
||||
resolve: {
|
||||
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS]
|
||||
extensions: [...SCRIPT_EXTS, ...STYLE_EXTS],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@@ -44,26 +44,26 @@ export const baseConfig = {
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
compilerOptions: {
|
||||
preserveWhitespace: false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
preserveWhitespace: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.(js|ts|jsx|tsx)$/,
|
||||
exclude: /node_modules\/(?!(@vant\/cli))/,
|
||||
use: [CACHE_LOADER, 'babel-loader']
|
||||
use: [CACHE_LOADER, 'babel-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
sideEffects: true,
|
||||
use: CSS_LOADERS
|
||||
use: CSS_LOADERS,
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
sideEffects: true,
|
||||
use: [...CSS_LOADERS, 'less-loader']
|
||||
use: [...CSS_LOADERS, 'less-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
@@ -73,22 +73,22 @@ export const baseConfig = {
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
implementation: sass
|
||||
}
|
||||
}
|
||||
]
|
||||
implementation: sass,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.md$/,
|
||||
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader']
|
||||
}
|
||||
]
|
||||
use: [CACHE_LOADER, 'vue-loader', '@vant/markdown-loader'],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new VueLoaderPlugin(),
|
||||
new FriendlyErrorsPlugin({
|
||||
clearConsole: false,
|
||||
logLevel: 'WARNING'
|
||||
})
|
||||
]
|
||||
logLevel: 'WARNING',
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
@@ -14,7 +14,7 @@ export function getPackageConfig(isMinify: boolean) {
|
||||
{
|
||||
mode: 'production',
|
||||
entry: {
|
||||
[name]: join(ES_DIR, 'index.js')
|
||||
[name]: join(ES_DIR, 'index.js'),
|
||||
},
|
||||
stats: 'none',
|
||||
output: {
|
||||
@@ -24,20 +24,20 @@ export function getPackageConfig(isMinify: boolean) {
|
||||
filename: isMinify ? '[name].min.js' : '[name].js',
|
||||
umdNamedDefine: true,
|
||||
// https://github.com/webpack/webpack/issues/6522
|
||||
globalObject: "typeof self !== 'undefined' ? self : this"
|
||||
globalObject: "typeof self !== 'undefined' ? self : this",
|
||||
},
|
||||
externals: {
|
||||
vue: {
|
||||
root: 'Vue',
|
||||
commonjs: 'vue',
|
||||
commonjs2: 'vue',
|
||||
amd: 'vue'
|
||||
}
|
||||
amd: 'vue',
|
||||
},
|
||||
},
|
||||
performance: false,
|
||||
optimization: {
|
||||
minimize: isMinify
|
||||
}
|
||||
minimize: isMinify,
|
||||
},
|
||||
},
|
||||
getWebpackConfig()
|
||||
);
|
||||
|
@@ -10,7 +10,7 @@ import { VantCliSitePlugin } from '../compiler/vant-cli-site-plugin';
|
||||
import {
|
||||
GREEN,
|
||||
SITE_MODILE_SHARED_FILE,
|
||||
SITE_DESKTOP_SHARED_FILE
|
||||
SITE_DESKTOP_SHARED_FILE,
|
||||
} from '../common/constant';
|
||||
|
||||
export function getSiteDevBaseConfig() {
|
||||
@@ -43,7 +43,7 @@ export function getSiteDevBaseConfig() {
|
||||
return merge(baseConfig as any, {
|
||||
entry: {
|
||||
'site-desktop': [join(__dirname, '../../site/desktop/main.js')],
|
||||
'site-mobile': [join(__dirname, '../../site/mobile/main.js')]
|
||||
'site-mobile': [join(__dirname, '../../site/mobile/main.js')],
|
||||
},
|
||||
devServer: {
|
||||
port: 8080,
|
||||
@@ -51,16 +51,16 @@ export function getSiteDevBaseConfig() {
|
||||
host: '0.0.0.0',
|
||||
stats: 'errors-only',
|
||||
publicPath: '/',
|
||||
disableHostCheck: true
|
||||
disableHostCheck: true,
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'site-mobile-shared': SITE_MODILE_SHARED_FILE,
|
||||
'site-desktop-shared': SITE_DESKTOP_SHARED_FILE
|
||||
}
|
||||
'site-desktop-shared': SITE_DESKTOP_SHARED_FILE,
|
||||
},
|
||||
},
|
||||
output: {
|
||||
chunkFilename: '[name].js'
|
||||
chunkFilename: '[name].js',
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
@@ -69,15 +69,15 @@ export function getSiteDevBaseConfig() {
|
||||
chunks: 'all',
|
||||
minChunks: 2,
|
||||
minSize: 0,
|
||||
name: 'chunks'
|
||||
}
|
||||
}
|
||||
}
|
||||
name: 'chunks',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
new WebpackBar({
|
||||
name: 'Vant Cli',
|
||||
color: GREEN
|
||||
color: GREEN,
|
||||
}),
|
||||
new VantCliSitePlugin(),
|
||||
new HtmlWebpackPlugin({
|
||||
@@ -87,7 +87,7 @@ export function getSiteDevBaseConfig() {
|
||||
chunks: ['chunks', 'site-desktop'],
|
||||
template: join(__dirname, '../../site/desktop/index.html'),
|
||||
filename: 'index.html',
|
||||
baiduAnalytics
|
||||
baiduAnalytics,
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title,
|
||||
@@ -96,9 +96,9 @@ export function getSiteDevBaseConfig() {
|
||||
chunks: ['chunks', 'site-mobile'],
|
||||
template: join(__dirname, '../../site/mobile/index.html'),
|
||||
filename: 'mobile.html',
|
||||
baiduAnalytics
|
||||
})
|
||||
]
|
||||
baiduAnalytics,
|
||||
}),
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -18,8 +18,8 @@ export function getSitePrdConfig() {
|
||||
publicPath,
|
||||
path: outputDir,
|
||||
filename: '[name].[hash:8].js',
|
||||
chunkFilename: 'async_[name].[chunkhash:8].js'
|
||||
}
|
||||
chunkFilename: 'async_[name].[chunkhash:8].js',
|
||||
},
|
||||
},
|
||||
getWebpackConfig()
|
||||
);
|
||||
|
Reference in New Issue
Block a user