Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ice-scripts/release-2.1.12 #66

Merged
merged 5 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.1.12

- [feat] support file watcher for compile library alibaba/ice#2844
- [feat] support cli option to disable open browser alibaba/ice#2875
- [fix] wrap lines when resolve sass import alibaba/ice#2876

## 2.1.11

- [fix] error mimetype of image
Expand Down
6 changes: 5 additions & 1 deletion packages/ice-plugin-component/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Changelog

## 0.1.7

- [feat] support option watch for compile library when source files changed

## 0.1.6

- [fix] externals react-dom

## 0.1.5

- [fix] fix: modular-import did not work with ice-plugin-component alibaba/ice#2724
- [fix] modular-import did not work with ice-plugin-component alibaba/ice#2724

## 0.1.4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ function dedupe(arr) {
// 为了让 require.resolve 可以解析 .jsx 和 .vue 文件
require.extensions['.jsx'] = require.extensions['.js'];
require.extensions['.vue'] = require.extensions['.js'];
const tracedFiles = {};

module.exports = function (entryFilePath) {
const tracedFiles = {};
let result = [];
trace(require.resolve(entryFilePath));

Expand Down

This file was deleted.

63 changes: 42 additions & 21 deletions packages/ice-plugin-component/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path');
const fse = require('fs-extra');
const clonedeep = require('lodash.clonedeep');
const chokidar = require('chokidar');
const resolveSassImport = require('resolve-sass-import');
const { getPkgJSONSync } = require('./utils/pkgJson');
const getDemoDir = require('./utils/getDemoDir');
const getDemos = require('./utils/getDemos');
Expand All @@ -9,15 +11,15 @@ const { parseMarkdownParts } = require('./compile/component/markdownHelper');
const buildSrc = require('./compile/component/buildSrc');
const modifyPkgHomePage = require('./compile/component/modifyPkgHomePage');
const ComponentStyleGenerator = require('./compile/fusion/componentStyleGenerator');
const resolveSassImport = require('./compile/fusion/resolveSassImport');
const baseConfig = require('./configs/base');
const devConfig = require('./configs/dev');
const buildConfig = require('./configs/build');
const adaptorBuildConfig = require('./configs/adaptorBuild');

let watcher = null;
module.exports = ({ context, chainWebpack, onHook, log }, opts = {}) => {
const { command, rootDir, reRun } = context;
const { type = 'fusion' } = opts;
const { type = 'fusion', watch } = opts;
const pkg = getPkgJSONSync(rootDir);
// store webpack chain config
let webpackChain;
Expand Down Expand Up @@ -74,32 +76,51 @@ module.exports = ({ context, chainWebpack, onHook, log }, opts = {}) => {
}
});

const compileLib = () => {
// get babel config after all plugin had been excuted
const babelConfig = clonedeep(webpackChain.module.rule('jsx').use('babel-loader').get('options'));
delete babelConfig.cacheDirectory;
// component buildSrc
buildSrc({ babelConfig, rootDir, log });
if (type === 'fusion') {
const styleGenerator = new ComponentStyleGenerator({
cwd: rootDir,
destPath: path.join(rootDir, 'lib'),
absoulte: false,
});

styleGenerator.writeStyleJSSync();
log.info('Generated style.js');

styleGenerator.writeIndexScssSync();
log.info('Generated index.scss');
}
};

if (!watcher && watch) {
const srcPath = path.join(rootDir, 'src');
log.info(`Start watch path: ${srcPath}`);
watcher = chokidar.watch(srcPath, {
ignoreInitial: true,
});

watcher.on('change', (file) => {
log.info(`${file} changed, start compile library.`);
compileLib();
});

watcher.on('error', (error) => {
log.error('fail to watch file', error);
});
}
// flag for run build again, only excute at the first time of load this plugin
if (!process.env.BUILD_AGAIN) {
// build src and umd adpator after demo build
onHook('afterBuild', () => {
process.env.BUILD_AGAIN = true;
// get babel config after all plugin had been excuted
const babelConfig = clonedeep(webpackChain.module.rule('jsx').use('babel-loader').get('options'));
delete babelConfig.cacheDirectory;
// component buildSrc
buildSrc({ babelConfig, rootDir, log });
compileLib();
modifyPkgHomePage(pkg, rootDir);

if (type === 'fusion') {
const styleGenerator = new ComponentStyleGenerator({
cwd: rootDir,
destPath: path.join(rootDir, 'lib'),
absoulte: false,
});

styleGenerator.writeStyleJSSync();
log.info('Generated style.js');

styleGenerator.writeIndexScssSync();
log.info('Generated index.scss');
}

if (hasAdaptor) {
// generate adaptor index.scss
const sassContent = resolveSassImport('main.scss', path.resolve(rootDir, 'src'));
Expand Down
6 changes: 4 additions & 2 deletions packages/ice-plugin-component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ice-plugin-component",
"version": "0.1.6",
"version": "0.1.7",
"description": "ice plugin for develop component",
"main": "lib/index.js",
"scripts": {
Expand All @@ -15,6 +15,7 @@
"dependencies": {
"@babel/core": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"chokidar": "^3.2.2",
"fs-extra": "^8.0.1",
"handlebars": "^4.1.2",
"handlebars-loader": "^1.7.1",
Expand All @@ -25,6 +26,7 @@
"marked": "^0.6.2",
"npmlog": "^4.1.2",
"prismjs": "^1.16.0",
"resolve": "^1.11.0"
"resolve": "^1.11.0",
"resolve-sass-import": "^0.1.0"
}
}
1 change: 1 addition & 0 deletions packages/ice-scripts/bin/child-process-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ program
.option('--analyzer-port', '设置分析端口号')
.option('--disabled-reload', '关闭 hot reload')
.option('--disabled-mock', '关闭 mock')
.option('--disabled-open', 'do not open browser after compile')
.option('--config <config>', 'use custom config')
.parse(process.argv);

Expand Down
4 changes: 3 additions & 1 deletion packages/ice-scripts/lib/commands/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ module.exports = async function(context, subprocess) {
` - Network: ${chalk.yellow(urls.lanUrlForTerminal)}`,
].join('\n')
);
openBrowser(urls.localUrlForBrowser);
if (!commandArgs.disabledOpen) {
openBrowser(urls.localUrlForBrowser);
}
}

applyHook('afterDev', stats);
Expand Down
2 changes: 1 addition & 1 deletion packages/ice-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ice-scripts",
"version": "2.1.11",
"version": "2.1.12",
"description": "ICE SDK",
"main": "index.js",
"bin": {
Expand Down
6 changes: 5 additions & 1 deletion packages/resolve-sass-import/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.1

- [fix] check wrap lines when resolve sass import

## 0.1.0

- [feat] basic feature for resolve sass import
- [feat] basic feature for resolve sass import
3 changes: 2 additions & 1 deletion packages/resolve-sass-import/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function resolveSassFile(sassFile, rootDir) {
}

if (resolvePath) {
return resolveSassFile(resolvePath, path.dirname(resolvePath));
const isLineWrap = /^\n/.exec(importStr);
return `${isLineWrap ? '\n' : ''}${resolveSassFile(resolvePath, path.dirname(resolvePath))}`;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/resolve-sass-import/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resolve-sass-import",
"version": "0.1.0",
"version": "0.1.1",
"description": "resolve sass import",
"main": "index.js",
"scripts": {
Expand Down