Skip to content

Commit 911c8bc

Browse files
committedDec 6, 2019
打包发布配置修改
1 parent 281831c commit 911c8bc

File tree

2 files changed

+47
-63
lines changed

2 files changed

+47
-63
lines changed
 

‎build/prod.js

+11-47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const webpack = require('webpack');
2-
const HtmlWebpackPlugin = require('html-webpack-plugin');
32
const CopyWebpackPlugin = require('copy-webpack-plugin');
43
const path = require('path');
54
const buildPath = path.resolve(__dirname, '../dist');
@@ -10,14 +9,12 @@ module.exports = {
109
mode: 'production',
1110
context: path.resolve(__dirname, '../src/components'), // 解析起点
1211
entry: {
13-
yuwan: './index.tsx',
14-
// "yuwan.min": './index.tsx',
12+
yuwan: ['./index.tsx', './style/index.scss'],
13+
"yuwan.min": './index.tsx'
1514
},
1615
output: {
1716
path: buildPath, // 输出文件存放在本地的目录
18-
// publicPath: './', // 配置发布到线上资源的 URL 前缀
19-
// chunkFilename: 'js/[name].[hash].js', // 无入口的chunk在输出时的文件名称
20-
filename: 'yuwan.js',
17+
filename: '[name].js',
2118
library: 'yuwan',
2219
libraryTarget: "umd"
2320
},
@@ -41,7 +38,7 @@ module.exports = {
4138
{
4239
test: /\.(less|css)$/,
4340
use: [
44-
'style-loader',
41+
MiniCssExtractPlugin.loader,
4542
'css-loader',
4643
{
4744
loader: 'less-loader',
@@ -54,7 +51,7 @@ module.exports = {
5451
{
5552
test: /\.(scss|sass)$/,
5653
use: [
57-
'style-loader', //上面的简写方式
54+
MiniCssExtractPlugin.loader,
5855
'css-loader',
5956
'sass-loader'
6057
]
@@ -69,9 +66,6 @@ module.exports = {
6966
hints: false,
7067
},
7168
optimization: {
72-
// runtimeChunk: {
73-
// name: 'manifest'
74-
// },
7569
minimize: true,
7670
noEmitOnErrors: true,
7771
minimizer: [
@@ -81,46 +75,16 @@ module.exports = {
8175
parallel: true,
8276
sourceMap: false
8377
}),
84-
new OptimizeCSSAssetsPlugin({})
78+
new OptimizeCSSAssetsPlugin({}),
8579
],
86-
splitChunks: {
87-
minSize: 30000,
88-
maxSize: 3000000,
89-
minChunks: 1,
90-
maxAsyncRequests: 5,
91-
maxInitialRequests: 3,
92-
name: true,
93-
// cacheGroups: {
94-
// vendor: {
95-
// chunks: 'initial',
96-
// name: 'vendor',
97-
// test: 'vendor'
98-
// },
99-
// echarts: {
100-
// chunks: 'all',
101-
// name: 'echarts',
102-
// test: /[\\/]echarts[\\/]/,
103-
// }
104-
// }
105-
}
10680
},
10781
plugins: [
108-
// new HtmlWebpackPlugin({
109-
// filename: 'index.html',
110-
// template: 'index.html',
111-
// }),
112-
// new webpack.NamedModulesPlugin(),
113-
// new webpack.optimize.OccurrenceOrderPlugin(true),
114-
// new MiniCssExtractPlugin({
115-
// filename: 'css/[name].[hash].css',
116-
// chunkFilename: 'css/[name].[hash].css'
117-
// }),
82+
new MiniCssExtractPlugin({
83+
filename: 'yuwan.css',
84+
}),
11885
new CopyWebpackPlugin([
119-
// {from: path.resolve(__dirname,'../public/config'),to:'config'},
120-
// {from: path.resolve(__dirname,'../public/mock'),to:'mock'},
121-
// {from: path.resolve(__dirname,'../public/images'),to:'images'},
122-
{ from: path.resolve(__dirname, '../public/fonts'), to: 'fonts' },
123-
// {from: path.resolve(__dirname,'../public/pages'),to:'pages'}
86+
// { from: path.resolve(__dirname, '../public/images'), to: 'images' },
87+
// { from: path.resolve(__dirname, '../public/fonts'), to: 'fonts' },
12488
]),
12589
new webpack.DefinePlugin({
12690
__PRODUCTION: JSON.stringify(true)

‎package.json

+36-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
{
22
"name": "yuwan",
3-
"version": "1.0.2",
3+
"version": "1.0.5",
44
"description": "components based on typescript & react",
5-
"main": "./dist/yuwan.js",
5+
"main": "./lib/index.js",
66
"author": "yuwan",
7+
"keywords": [
8+
"ant",
9+
"components",
10+
"react",
11+
"react-component",
12+
"ui",
13+
"typescript"
14+
],
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/nankaNULL/react-typescript-components"
18+
},
719
"files": [
8-
"dist"
20+
"dist",
21+
"lib"
922
],
1023
"scripts": {
11-
"build": "rimraf dist && webpack --bail --progress --profile --config ./build/prod.js",
24+
"build": "rimraf dist && cross-env NODE_ENV=production webpack --bail --progress --profile --config ./build/prod.js",
25+
"compile": "rimraf lib && npx babel src/components --out-dir lib --extensions '.tsx' --copy-files",
26+
"compile-css": "node-sass src/components --output lib",
1227
"dev": "webpack-dev-server --progress --colors --config ./build/dev.js",
1328
"test-watch": "karma start --auto-watch --no-single-run",
1429
"start": "npm run dev",
15-
"preview": "pushstate-server ./dist 1234"
30+
"preview": "pushstate-server ./dist 1234",
31+
"publish": "npm publish"
1632
},
1733
"dependencies": {
34+
"@babel/runtime-corejs2": "^7.7.2",
1835
"@types/prop-types": "^15.7.3",
1936
"@types/shallowequal": "^1.1.1",
2037
"antd": "^3.25.2",
@@ -31,24 +48,26 @@
3148
"shallowequal": "^1.1.0"
3249
},
3350
"devDependencies": {
34-
"@babel/core": "^7.7.2",
35-
"@babel/plugin-proposal-class-properties": "^7.7.0",
36-
"@babel/plugin-proposal-decorators": "^7.7.0",
37-
"@babel/plugin-transform-runtime": "^7.6.2",
51+
"@babel/cli": "^7.7.4",
52+
"@babel/core": "^7.7.4",
53+
"@babel/plugin-proposal-class-properties": "^7.7.4",
54+
"@babel/plugin-proposal-decorators": "^7.7.4",
55+
"@babel/plugin-transform-runtime": "^7.7.4",
3856
"@babel/polyfill": "^7.7.0",
39-
"@babel/preset-env": "^7.7.1",
40-
"@babel/preset-react": "^7.7.0",
41-
"@babel/runtime": "^7.7.2",
42-
"@babel/runtime-corejs2": "^7.7.2",
57+
"@babel/preset-env": "^7.7.4",
58+
"@babel/preset-react": "^7.7.4",
59+
"@babel/preset-typescript": "^7.7.4",
60+
"@babel/runtime": "^7.7.4",
4361
"@types/classnames": "^2.2.9",
4462
"@types/lodash": "^4.14.148",
4563
"@types/react-dom": "^16.9.4",
4664
"@types/react-redux": "^7.1.5",
4765
"@types/react-router-dom": "^5.1.2",
4866
"@types/react-router-redux": "^5.0.18",
4967
"babel-loader": "^8.0.6",
50-
"babel-plugin-import": "^1.12.2",
68+
"babel-plugin-import": "^1.13.0",
5169
"copy-webpack-plugin": "^5.0.5",
70+
"cross-env": "^6.0.3",
5271
"css-loader": "^3.2.0",
5372
"file-loader": "^4.2.0",
5473
"html-webpack-plugin": "^3.2.0",
@@ -71,6 +90,7 @@
7190
"uglifyjs-webpack-plugin": "^2.2.0",
7291
"webpack": "^4.41.2",
7392
"webpack-cli": "^3.3.10",
74-
"webpack-dev-server": "^3.9.0"
93+
"webpack-dev-server": "^3.9.0",
94+
"yuwan": "^1.0.5"
7595
}
76-
}
96+
}

0 commit comments

Comments
 (0)
Please sign in to comment.