san-xui
san-xui 是基于 san 开发的一套UI组件库,在百度云的控制台中得到了广泛的应用。
下载
NPM:
npm i --save san-xui
使用
Webpack
通过 named import 导入所需要使用的组件
import 'san-xui/dist/xui.css';
import {defineComponent} from 'san';
import {Button} from 'san-xui';
const App = defineComponent({
template: `<template><ui-button>Hello san-xui</ui-button></template>`,
components: {
'ui-button': Button
}
});
const app = new App();
app.attach(document.body);
webpack.config.js
需要安装必要的一些插件
npm i --save-dev babel-loader css-loader style-loader less-loader less file-loader babel-preset-stage-0 babel-preset-env
然后补充上一些相关的配置
const path = require('path');
function alias(name) {
return path.dirname(require.resolve(name));
}
module.exports = {
...
resolve: {
extensions: ['.js', '.jsx', '.es6'],
mainFiles: ['index', 'main'],
alias: {
'eoo': alias('@ecomfe/eoo'),
'mini-event': alias('@ecomfe/mini-event'),
'er': alias('@ecomfe/er'),
'inf-ria': alias('@ecomfe/inf-ria'),
'inf-i18n': alias('@ecomfe/inf-i18n')
}
},
module: {
rules: [
{
test: /\.(png|gif|jpe?g|svg)$/,
use: [
{
loader: 'file-loader',
options: {
name(file) {
return 'assets/images/[hash].[ext]';
}
}
}
]
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.less$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
{
loader: 'less-loader',
options: {
relativeUrls: true,
paths: []
}
}
]
},
{
test: /\.es6$/,
use: {
loader: 'babel-loader',
options: {
presets: ['env', 'stage-0']
}
}
},
{
test: /\.js$/,
exclude: /(node_modules|dist)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env', 'stage-0']
}
}
}
]
},
...
}