Skip to content

Commit ec05fc5

Browse files
committed
修改config
1 parent dd9e90d commit ec05fc5

7 files changed

+79
-38
lines changed

Diff for: dist/build.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
</head>
77
<body>
88
<div id="app"></div>
9-
<script src="dist/build.js"></script>
9+
<script src="demo/build.js"></script>
1010
</body>
1111
</html>

Diff for: package-lock.json

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "vue2-datepicker",
33
"description": "A Datepicker Component For Vue2",
44
"main": "dist/build.js",
5-
"version": "1.8.1",
5+
"version": "1.8.2",
66
"scripts": {
77
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
8-
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
8+
"demo": "cross-env NODE_ENV=production webpack --progress --hide-modules --config webpack.demo.config.js",
9+
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules --config webpack.build.config.js"
910
},
1011
"repository": {
1112
"type": "git",
@@ -49,6 +50,7 @@
4950
"vue-loader": "^13.0.5",
5051
"vue-template-compiler": "^2.2.1",
5152
"webpack": "^2.2.0",
52-
"webpack-dev-server": "^2.2.0"
53+
"webpack-dev-server": "^2.2.0",
54+
"webpack-merge": "^4.1.1"
5355
}
5456
}

Diff for: webpack.build.config.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const path = require('path')
2+
const merge = require('webpack-merge')
3+
const baseWebpackConfig = require('./webpack.config.js')
4+
const webpack = require('webpack')
5+
6+
const webpackConfig = merge(baseWebpackConfig, {
7+
entry: './index.js',
8+
output: {
9+
path: path.resolve(__dirname, './dist'),
10+
publicPath: '/dist/',
11+
filename: 'build.js',
12+
library: "DatePicker",
13+
libraryTarget: "umd"
14+
},
15+
devtool: 'source-map',
16+
plugins: [
17+
new webpack.DefinePlugin({
18+
'process.env': {
19+
NODE_ENV: '"production"'
20+
}
21+
}),
22+
new webpack.optimize.UglifyJsPlugin({
23+
sourceMap: false,
24+
compress: {
25+
warnings: false
26+
}
27+
}),
28+
new webpack.LoaderOptionsPlugin({
29+
minimize: true
30+
})
31+
]
32+
})
33+
34+
module.exports = webpackConfig

Diff for: webpack.config.js

+3-32
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ var webpack = require('webpack')
44
module.exports = {
55
entry: './demo/main.js',
66
output: {
7-
path: path.resolve(__dirname, './dist'),
8-
publicPath: '/dist/',
9-
filename: 'build.js',
10-
library: "DatePicker",
11-
libraryTarget: "umd"
7+
path: path.resolve(__dirname, './demo'),
8+
publicPath: '/demo/',
9+
filename: 'build.js'
1210
},
1311
module: {
1412
rules: [
@@ -35,11 +33,6 @@ module.exports = {
3533
}
3634
]
3735
},
38-
resolve: {
39-
alias: {
40-
// 'vue$': 'vue/dist/vue.esm.js'
41-
}
42-
},
4336
devServer: {
4437
historyApiFallback: true,
4538
noInfo: true,
@@ -50,25 +43,3 @@ module.exports = {
5043
},
5144
devtool: '#eval-source-map'
5245
}
53-
54-
if (process.env.NODE_ENV === 'production') {
55-
module.exports.entry = './index.js'
56-
module.exports.devtool = '#source-map'
57-
// http://vue-loader.vuejs.org/en/workflow/production.html
58-
module.exports.plugins = (module.exports.plugins || []).concat([
59-
new webpack.DefinePlugin({
60-
'process.env': {
61-
NODE_ENV: '"production"'
62-
}
63-
}),
64-
new webpack.optimize.UglifyJsPlugin({
65-
sourceMap: false,
66-
compress: {
67-
warnings: false
68-
}
69-
}),
70-
new webpack.LoaderOptionsPlugin({
71-
minimize: true
72-
})
73-
])
74-
}

Diff for: webpack.demo.config.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const merge = require('webpack-merge')
2+
const baseWebpackConfig = require('./webpack.config.js')
3+
const webpack = require('webpack')
4+
5+
const webpackConfig = merge(baseWebpackConfig, {
6+
devtool: 'source-map',
7+
plugins: [
8+
new webpack.DefinePlugin({
9+
'process.env': {
10+
NODE_ENV: '"production"'
11+
}
12+
}),
13+
new webpack.optimize.UglifyJsPlugin({
14+
sourceMap: false,
15+
compress: {
16+
warnings: false
17+
}
18+
}),
19+
new webpack.LoaderOptionsPlugin({
20+
minimize: true
21+
})
22+
]
23+
})
24+
25+
module.exports = webpackConfig

0 commit comments

Comments
 (0)