Skip to content

Commit

Permalink
修改antd不能按需的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zkeyword committed Jul 9, 2018
1 parent 0fb1d14 commit 64765e3
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 20 deletions.
8 changes: 1 addition & 7 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
}
],
["import", { "libraryName": "antd", "libraryDirectory": "lib", "style": "css" }],
"syntax-dynamic-import",
[
"import-inspector",
{
"serverSideRequirePath": true
}
]
"syntax-dynamic-import"
]
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

## 执行步骤

> client 端和 server 端 tsconfig.json 不是同一份
1、 npm i

2、编辑 ormconfig.json 文件,写入mysql配置
Expand Down Expand Up @@ -76,9 +78,9 @@ npm i -g typescript

- ~~完成基本骨架~~
- ~~引入stylus~~
- 完成页面逻辑
- ~~引入mobx~~
- ~~完善webpack配置~~
- ~~antd 按需加载不成功的bug~~
- 完成页面逻辑
- 引入热更新
- 考虑使用parcel
- ~~完善webpack配置~~
- antd 按需加载不成功的bug
30 changes: 30 additions & 0 deletions build/tsconfig.prod.client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "2.0.2",
"compilerOptions": {
"lib": [
"es6",
"dom"
],
"target": "es6",
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"rootDir": "../src/client",
"outDir": "../dist/client",
"sourceMap": true,
"jsx": "react"
},
"exclude": [
"node_modules",
"dist"
],
"include": [
"../src/client/**/*"
],
"files": [
"../src/types/vendor.d.ts"
],
"emitDecoratorMetadata": true,
"experimentalDecorators": true
}
6 changes: 2 additions & 4 deletions build/webpack.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const chalk = require('chalk');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const nodeModules = path.resolve(__dirname, '../node_modules');

const isDev = !!(process.env.NODE_ENV != 'production');
const isDev = !!(process.env.NODE_ENV !== 'production');

function createHappyPlugin(id, loaders) {
return new HappyPack({
Expand All @@ -21,7 +21,6 @@ module.exports = {
rules: [
{
test: /\.(js|jsx)$/,
exclude: nodeModules,
use: ['happypack/loader?id=happy-babel-js']
},
// {
Expand All @@ -34,7 +33,6 @@ module.exports = {
// },
{
test: /\.css$/,
exclude: nodeModules,
use: isDev ? ['style-loader', 'happypack/loader?id=happy-css'] : [
"style-loader", MiniCssExtractPlugin.loader, {
loader: 'css-loader',
Expand Down Expand Up @@ -103,7 +101,7 @@ module.exports = {
noParse: /node_modules\/(jquey|js\-cookie\.js)/
},
resolve: {
extensions: ['.js', '.jsx']
extensions: ['.js', '.jsx', '.ts', '.tsx']
},
plugins: [
new MiniCssExtractPlugin({
Expand Down
7 changes: 6 additions & 1 deletion build/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = merge(baseWebpackConfig, {
devtool: 'source-map',
mode: "development",
entry: {
blog: './dist/client/index.js'
blog: './src/client/index.tsx'

},
output: {
Expand All @@ -18,6 +18,11 @@ module.exports = merge(baseWebpackConfig, {
filename: '[name].js',
chunkFilename: "[name].js"
},
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader' },
]
},
plugins: [
new Html({
filename: 'blog.html',
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@
"typeorm": "^0.1.0"
},
"scripts": {
"build:prod": "npm run cp && cross-env NODE_ENV=production webpack --config ./build/webpack.prod.config.js --progress",
"build:prod": "npm run tsc:prod && npm run cp && cross-env NODE_ENV=production webpack --config ./build/webpack.prod.config.js --progress",
"build:dev": "cross-env NODE_ENV=development webpack --config ./build/webpack.dev.config.js --progress --watch",
"start": "cross-env NODE_ENV=production && cross-env RENDER_TYPE=server node dist/server/index.js",
"dev": "cross-env NODE_ENV=development && cross-env RENDER_TYPE=server ./node_modules/.bin/nodemon dist/server/index.js --config ./nodemonConfig.json",
"dev": "cross-env NODE_ENV=development && cross-env RENDER_TYPE=server ./node_modules/.bin/nodemon dist/server/index.js -e ts --exec 'ts-node' --config ./nodemonConfig.json",
"dll": "webpack --config ./build/webpack.dll.config.js",
"fixed": "tslint --fix --project tsconfig.json 'src/**/*.ts*'",
"cp": "cpx src/client/assets/**/* dist/client/assets/"
"cp": "cpx src/client/assets/**/* dist/client/assets/",
"tsc:prod": "tsc -p build/tsconfig.prod.client.json"
}
}
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"version": "2.0.2",
"compilerOptions": {
"lib": [
"es5",
"es6",
"dom"
],
Expand All @@ -13,7 +12,6 @@
"experimentalDecorators": true,
"rootDir": "./src",
"outDir": "./dist",
"watch": true,
"sourceMap": true,
"jsx": "react"
},
Expand Down

0 comments on commit 64765e3

Please sign in to comment.