Skip to content

Commit

Permalink
Merge pull request #987 from alibaba/rax-scripts
Browse files Browse the repository at this point in the history
rax-scripts 1.2.0
  • Loading branch information
yuanyan authored Mar 20, 2019
2 parents 15547c8 + adea9d8 commit 9391edb
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/rax-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rax-cli",
"version": "1.1.0",
"version": "1.2.0",
"license": "BSD-3-Clause",
"description": "Command line interface for Rax",
"main": "src/index.js",
Expand Down
7 changes: 1 addition & 6 deletions packages/rax-cli/src/generator/miniapp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rax-starter-kit
# MiniApp Starter Kit

## Getting Started

Expand All @@ -17,8 +17,3 @@ You will see the lint errors in the console.
### `npm run build`

Builds the app for production to the `build` folder.

## Universal "Gotchas"

- DOM & DOM like **`window`** & **`document`** do not exist on the server - so using them, or any library that uses them (jQuery for example) will not work.
- If you need to use them, consider limiting them to wrapping them situationally with the imported *isWeb / isNode / isWeex* features from Universal. `import {isWeb, isWeex, isNode} from 'universal-env'`;
2 changes: 1 addition & 1 deletion packages/rax-cli/src/generator/miniapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"rax": "^1.0.0"
},
"devDependencies": {
"rax-scripts": "^1.1.0",
"rax-scripts": "^1.2.0",
"eslint": "^5.15.1",
"babel-eslint": "^10.0.1"
}
Expand Down
7 changes: 6 additions & 1 deletion packages/rax-cli/src/generator/webapp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rax-starter-kit
# WebApp Starter Kit

## Getting Started

Expand All @@ -17,3 +17,8 @@ You will see the lint errors in the console.
### `npm run build`

Builds the app for production to the `build` folder.


## Post-Processing CSS

You can customize your target support browsers by adjusting the `browserslist` key in `package.json` according to the [Browserslist specification](https://github.com/browserslist/browserslist#readme).
6 changes: 5 additions & 1 deletion packages/rax-cli/src/generator/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "__YourProjectName__",
"author": "__AuthorName__",
"version": "0.0.0",
"browserslist": [
"last 1 version",
"> 1%"
],
"scripts": {
"start": "rax-scripts start",
"build": "rax-scripts build",
Expand All @@ -12,7 +16,7 @@
"driver-dom": "^1.0.0"
},
"devDependencies": {
"rax-scripts": "^1.1.0",
"rax-scripts": "^1.2.0",
"eslint": "^5.15.1",
"babel-eslint": "^10.0.1",
"eslint-plugin-react": "^7.12.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/rax-cli/src/generator/weexapp/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rax-starter-kit
# WeexApp Starter Kit

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion packages/rax-cli/src/generator/weexapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"driver-weex": "^1.0.0"
},
"devDependencies": {
"rax-scripts": "^1.1.0",
"rax-scripts": "^1.2.0",
"eslint": "^5.15.1",
"babel-eslint": "^10.0.1",
"eslint-plugin-react": "^7.12.4"
Expand Down
8 changes: 5 additions & 3 deletions packages/rax-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rax-scripts",
"version": "1.1.0",
"version": "1.2.0",
"license": "BSD-3-Clause",
"description": "Project scripts for Rax.",
"bin": {
Expand Down Expand Up @@ -44,19 +44,21 @@
"commander": "^2.19.0",
"copy-webpack-plugin": "^4.6.0",
"cross-spawn": "^6.0.5",
"css-loader": "^2.1.0",
"css-loader": "^2.1.1",
"decamelize": "^2.0.0",
"file-loader": "^2.0.0",
"glob": "^7.1.3",
"html-webpack-plugin": "^3.2.0",
"image-source-loader": "^0.6.5",
"internal-ip": "^3.0.1",
"json-loader": "^0.5.7",
"loader-utils": "^1.1.0",
"mini-css-extract-plugin": "^0.5.0",
"minimatch": "^3.0.4",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"path-exists": "^3.0.0",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.6.0",
"rax-hot-loader": "^0.6.5",
"rax-hot-module-replacement-webpack-plugin": "^0.6.5",
"rax-webpack-plugin": "^0.6.5",
Expand Down
36 changes: 22 additions & 14 deletions packages/rax-scripts/src/config/webapp/webpack.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpackConfig = require('../webpack.config');
const pathConfig = require('../path.config');
const babelConfig = require('../babel.config');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

babelConfig.presets.push([
require.resolve('@babel/preset-react'), {
Expand All @@ -13,10 +14,6 @@ babelConfig.presets.push([
}
]);

babelConfig.plugins.push(
require.resolve('babel-plugin-transform-jsx-stylesheet')
);

module.exports = {
mode: webpackConfig.mode,
context: webpackConfig.context,
Expand All @@ -32,6 +29,10 @@ module.exports = {
inject: true,
template: pathConfig.appHtml,
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[id].css',
}),
webpackConfig.plugins.define,
webpackConfig.plugins.caseSensitivePaths,
process.env.ANALYZER ? new BundleAnalyzerPlugin() : null,
Expand Down Expand Up @@ -61,19 +62,26 @@ module.exports = {
test: /\.css$/,
use: [
{
loader: require.resolve('stylesheet-loader'),
loader: MiniCssExtractPlugin.loader,
},
],
},
// JSON is not enabled by default in Webpack but both Node and Browserify
// allow it implicitly so we also enable it.
{
test: /\.json$/,
use: [
{
loader: require.resolve('json-loader'),
loader: require.resolve('css-loader'),
},
],
{
loader: require.resolve('postcss-loader'),
options: {
ident: 'postcss',
plugins: () => [
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
}),
],
}
},
]
},
// load inline images using image-source-loader for Image
{
Expand Down
17 changes: 12 additions & 5 deletions packages/rax-scripts/src/config/webapp/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const pathConfig = require('../path.config');
const webpackMerge = require('webpack-merge');
const webpackConfigBase = require('./webpack.config.base');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');

const webpackConfigProd = webpackMerge(webpackConfigBase, {
target: 'node',
Expand All @@ -13,11 +14,17 @@ const webpackConfigProd = webpackMerge(webpackConfigBase, {
},
optimization: {
minimize: true,
minimizer: [new UglifyJSPlugin({
include: /\.min\.js$/,
cache: true,
sourceMap: true,
})]
minimizer: [
new UglifyJSPlugin({
include: /\.min\.js$/,
cache: true,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin({
// A boolean indicating if the plugin can print messages to the console
canPrint: true
})
]
},
});

Expand Down
10 changes: 0 additions & 10 deletions packages/rax-scripts/src/config/weexapp/webpack.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ module.exports = {
},
],
},
// JSON is not enabled by default in Webpack but both Node and Browserify
// allow it implicitly so we also enable it.
{
test: /\.json$/,
use: [
{
loader: require.resolve('json-loader'),
},
],
},
// load inline images using image-source-loader for Image
{
test: /\.(svg|png|webp|jpe?g|gif)$/i,
Expand Down

0 comments on commit 9391edb

Please # to comment.