Skip to content

Commit

Permalink
修改打包时babel-loader处理目录 (#78)
Browse files Browse the repository at this point in the history
* fix(): winex修改为winfe

* feat(): 修改babel-loader作用目录

* feat(): 增加公共样式文件

Co-authored-by: huzhiwei <865953771@qq.com>
  • Loading branch information
frontHu and huzhiwei committed Jul 21, 2021
1 parent 62c1a7f commit fb03d5c
Show file tree
Hide file tree
Showing 13 changed files with 2,127 additions and 26 deletions.
3 changes: 3 additions & 0 deletions packages/cli-plugin-fire/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"lru-cache": "^5.1.1",
"mini-css-extract-plugin": "^0.6.0",
"minio": "^7.0.18",
"node-sass": "4.14.0",
"npmlog": "^4.1.2",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"ora": "^5.4.0",
Expand All @@ -72,8 +73,10 @@
"progress-bar-webpack-plugin": "^2.1.0",
"readline": "^1.3.0",
"resolve-url-loader": "^4.0.0",
"sass-loader": "7.0.1",
"semver": "^7.3.5",
"strip-json-comments": "^3.1.1",
"style-resources-loader": "^1.4.1",
"terser-webpack-plugin": "^4.2.3",
"toml": "^3.0.0",
"upath": "^2.0.1",
Expand Down
9 changes: 8 additions & 1 deletion packages/cli-plugin-fire/src/build/webpack.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import TerserPlugin from 'terser-webpack-plugin';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import assets from './assets'
import path from 'path'

// resolve
export const resolve = {
Expand Down Expand Up @@ -34,7 +35,7 @@ export const externals = {
export const rules = [
{
test: /\.(js|jsx?|babel|es6)$/,
include: process.cwd(),
// include: process.cwd(),
exclude: /node_modules/,
loader: "babel-loader",
options: {
Expand Down Expand Up @@ -65,6 +66,12 @@ export const rules = [
options: {
sourceMap: true
}
},
{
loader: "style-resources-loader",
options: {
patterns: [path.resolve(__dirname, "./../styles/index.scss")],
},
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ export default function createBaseConfig(
createCSSRule('stylus', /\.styl(us)?$/, 'stylus-loader', {
preferPathResolver: 'webpack'
});
createCSSRule('scss', /\.scss$/, 'style-resources-loader', {
patterns: [path.resolve(__dirname, "../../styles/index.scss")],
});

config.plugin('vue-loader').use(VueLoaderPlugin);

Expand Down Expand Up @@ -263,7 +266,6 @@ export default function createBaseConfig(

pluginAPI.applySyncOption('define', config);
pluginAPI.applySyncOption('alias', config);

return config;
};

Expand Down
109 changes: 109 additions & 0 deletions packages/cli-plugin-fire/src/styles/_button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
@import "./var";
@mixin button-plain($color) {
color: $color;
background: mix($--color-white, $color, 90%);
border-color: mix($--color-white, $color, 60%);

&:hover,
&:focus {
background: $color;
border-color: $color;
color: $--color-white;
}

&:active {
background: mix($--color-black, $color, $--button-active-shade-percent);
border-color: mix($--color-black, $color, $--button-active-shade-percent);
color: $--color-white;
outline: none;
}

&.is-disabled {
&,
&:hover,
&:focus,
&:active {
color: mix($--color-white, $color, 40%);
background-color: mix($--color-white, $color, 90%);
border-color: mix($--color-white, $color, 80%);
}
}
}

@mixin button-variant($color, $background-color, $border-color) {
color: $color;
background-color: $background-color;
border-color: $border-color;

&:hover,
&:focus {
// background: mix(
// $--color-white,
// $background-color,
// $--button-hover-tint-percent
// );
// border-color: mix(
// $--color-white,
// $border-color,
// $--button-hover-tint-percent
// );
// color: $color;
}

&:active {
// background: mix(
// $--color-black,
// $background-color,
// $--button-active-shade-percent
// );
// border-color: mix(
// $--color-black,
// $border-color,
// $--button-active-shade-percent
// );
// color: $color;
// outline: none;
}

&.is-active {
// background: mix(
// $--color-black,
// $background-color,
// $--button-active-shade-percent
// );
// border-color: mix(
// $--color-black,
// $border-color,
// $--button-active-shade-percent
// );
// color: $color;
}

&.is-disabled {
&,
&:hover,
&:focus,
&:active {
color: $--color-white;
background-color: mix($background-color, $--color-white);
border-color: mix($border-color, $--color-white);
}
}

&.is-plain {
@include button-plain($background-color);
}
}
@mixin button-size(
$padding-vertical,
$padding-horizontal,
$font-size,
$border-radius
) {
padding: $padding-vertical $padding-horizontal;
font-size: $font-size;
border-radius: $border-radius;
&.is-round {
padding: $padding-vertical $padding-horizontal;
}
}
5 changes: 5 additions & 0 deletions packages/cli-plugin-fire/src/styles/config.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$namespace: 'el';
$winingspace: 'win';
$element-separator: '__';
$modifier-separator: '--';
$state-prefix: 'is-';
44 changes: 44 additions & 0 deletions packages/cli-plugin-fire/src/styles/function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@import "config";

/* BEM support Func
-------------------------- */
@function selectorToString($selector) {
$selector: inspect($selector);
$selector: str-slice($selector, 2, -2);
@return $selector;
}

@function containsModifier($selector) {
$selector: selectorToString($selector);

@if str-index($selector, $modifier-separator) {
@return true;
} @else {
@return false;
}
}

@function containWhenFlag($selector) {
$selector: selectorToString($selector);

@if str-index($selector, '.' + $state-prefix) {
@return true
} @else {
@return false
}
}

@function containPseudoClass($selector) {
$selector: selectorToString($selector);

@if str-index($selector, ':') {
@return true
} @else {
@return false
}
}

@function hitAllSpecialNestRule($selector) {

@return containsModifier($selector) or containWhenFlag($selector) or containPseudoClass($selector);
}
8 changes: 8 additions & 0 deletions packages/cli-plugin-fire/src/styles/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import "./button.scss";
@import "./config.scss";
@import "./function.scss";
@import "./mixins.scss";
@import "./popup.scss";
@import "./transition.scss";
@import "./utils.scss";
@import "./var.scss";
Loading

0 comments on commit fb03d5c

Please sign in to comment.