mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: use build command in vant cli
This commit is contained in:
parent
d1e55e82a3
commit
4dbd444679
@ -1,34 +0,0 @@
|
|||||||
/**
|
|
||||||
* Build npm lib
|
|
||||||
*/
|
|
||||||
const shell = require('shelljs');
|
|
||||||
const signale = require('signale');
|
|
||||||
|
|
||||||
const { Signale } = signale;
|
|
||||||
const tasks = [
|
|
||||||
'npm run bootstrap',
|
|
||||||
'npm run lint',
|
|
||||||
'npm run build:entry',
|
|
||||||
'node build/build-components.js',
|
|
||||||
'node build/build-style.js',
|
|
||||||
'node build/build-style-entry.js',
|
|
||||||
'cross-env NODE_ENV=production webpack --color --config build/webpack.pkg.js',
|
|
||||||
'cross-env NODE_ENV=production webpack -p --color --config build/webpack.pkg.js'
|
|
||||||
];
|
|
||||||
|
|
||||||
tasks.every(task => {
|
|
||||||
signale.start(task);
|
|
||||||
|
|
||||||
const interactive = new Signale({ interactive: true });
|
|
||||||
interactive.pending(task);
|
|
||||||
|
|
||||||
const result = shell.exec(`${task} --silent`);
|
|
||||||
|
|
||||||
if (result.code !== 0) {
|
|
||||||
interactive.error(task);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
interactive.success(task);
|
|
||||||
return true;
|
|
||||||
});
|
|
@ -1,66 +0,0 @@
|
|||||||
const fs = require('fs-extra');
|
|
||||||
const glob = require('fast-glob');
|
|
||||||
const path = require('path');
|
|
||||||
const less = require('less');
|
|
||||||
const csso = require('csso');
|
|
||||||
const postcss = require('postcss');
|
|
||||||
const postcssrc = require('postcss-load-config');
|
|
||||||
|
|
||||||
async function compileLess(lessCodes, paths) {
|
|
||||||
const outputs = await Promise.all(
|
|
||||||
lessCodes.map((source, index) =>
|
|
||||||
less.render(source, {
|
|
||||||
paths: [path.resolve(__dirname, 'node_modules')],
|
|
||||||
filename: paths[index]
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return outputs.map(item => item.css);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function compilePostcss(cssCodes, paths) {
|
|
||||||
const postcssConfig = await postcssrc();
|
|
||||||
const outputs = await Promise.all(
|
|
||||||
cssCodes.map((css, index) =>
|
|
||||||
postcss(postcssConfig.plugins).process(css, { from: paths[index] })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return outputs.map(item => item.css);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function compileCsso(cssCodes) {
|
|
||||||
return cssCodes.map(css => csso.minify(css).css);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function dest(output, paths) {
|
|
||||||
await Promise.all(
|
|
||||||
output.map((css, index) => fs.writeFile(paths[index].replace('.less', '.css'), css))
|
|
||||||
);
|
|
||||||
|
|
||||||
// icon.less should be replaced by compiled file
|
|
||||||
const iconCss = await glob(['./es/icon/*.css', './lib/icon/*.css'], { absolute: true });
|
|
||||||
iconCss.forEach(file => {
|
|
||||||
fs.copyFileSync(file, file.replace('.css', '.less'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// compile component css
|
|
||||||
async function compile() {
|
|
||||||
let codes;
|
|
||||||
try {
|
|
||||||
const paths = await glob(['./es/**/*.less', './lib/**/*.less'], { absolute: true });
|
|
||||||
|
|
||||||
codes = await Promise.all(paths.map(path => fs.readFile(path, 'utf-8')));
|
|
||||||
codes = await compileLess(codes, paths);
|
|
||||||
codes = await compilePostcss(codes, paths);
|
|
||||||
codes = await compileCsso(codes);
|
|
||||||
|
|
||||||
await dest(codes, paths);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compile();
|
|
@ -1,28 +0,0 @@
|
|||||||
#!/usr/bin/env sh
|
|
||||||
set -e
|
|
||||||
echo "Enter release version: "
|
|
||||||
read VERSION
|
|
||||||
|
|
||||||
read -p "Releasing $VERSION - are you sure? (y/n)" -n 1 -r
|
|
||||||
echo # (optional) move to a new line
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
# build
|
|
||||||
npm version $VERSION --no-git-tag-version
|
|
||||||
VERSION=$VERSION npm run build:lib
|
|
||||||
|
|
||||||
# commit
|
|
||||||
git tag v$VERSION
|
|
||||||
git commit -am "build: release $VERSION"
|
|
||||||
|
|
||||||
# publish
|
|
||||||
git push origin dev
|
|
||||||
git push origin refs/tags/v$VERSION
|
|
||||||
|
|
||||||
if [[ $VERSION =~ [beta] ]]
|
|
||||||
then
|
|
||||||
npm publish --tag beta
|
|
||||||
else
|
|
||||||
npm publish
|
|
||||||
fi
|
|
||||||
fi
|
|
@ -1,33 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
const merge = require('webpack-merge');
|
|
||||||
const config = require('./webpack.base');
|
|
||||||
|
|
||||||
const isMinify = process.argv.indexOf('-p') !== -1;
|
|
||||||
|
|
||||||
module.exports = merge(config, {
|
|
||||||
mode: 'production',
|
|
||||||
entry: {
|
|
||||||
vant: './es/index.js'
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: path.join(__dirname, '../lib'),
|
|
||||||
library: 'vant',
|
|
||||||
libraryTarget: 'umd',
|
|
||||||
filename: isMinify ? '[name].min.js' : '[name].js',
|
|
||||||
umdNamedDefine: true,
|
|
||||||
// https://github.com/webpack/webpack/issues/6522
|
|
||||||
globalObject: 'typeof self !== \'undefined\' ? self : this'
|
|
||||||
},
|
|
||||||
externals: {
|
|
||||||
vue: {
|
|
||||||
root: 'Vue',
|
|
||||||
commonjs: 'vue',
|
|
||||||
commonjs2: 'vue',
|
|
||||||
amd: 'vue'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
performance: false,
|
|
||||||
optimization: {
|
|
||||||
minimize: isMinify
|
|
||||||
}
|
|
||||||
});
|
|
@ -18,11 +18,10 @@
|
|||||||
"lint": "vant-cli lint",
|
"lint": "vant-cli lint",
|
||||||
"build:entry": "node build/build-entry.js",
|
"build:entry": "node build/build-entry.js",
|
||||||
"build:changelog": "vant-cli changelog ./docs/markdown/changelog.generated.md --tag v2.2.0",
|
"build:changelog": "vant-cli changelog ./docs/markdown/changelog.generated.md --tag v2.2.0",
|
||||||
"build:lib": "node build/build-lib.js",
|
|
||||||
"test": "vant-cli test",
|
"test": "vant-cli test",
|
||||||
"test:watch": "vant-cli test --watch",
|
"test:watch": "vant-cli test --watch",
|
||||||
"test:coverage": "open test/coverage/index.html",
|
"test:coverage": "open test/coverage/index.html",
|
||||||
"release": "sh build/release.sh",
|
"release": "vant-cli release",
|
||||||
"release:site": "sh build/release-site.sh"
|
"release:site": "sh build/release-site.sh"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
plugins: {
|
|
||||||
autoprefixer: {}
|
|
||||||
}
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user