Skip to content

Commit 8cef62d

Browse files
committed
add main.js to package.json.
remove dist from gitignore.
1 parent e789be8 commit 8cef62d

File tree

9 files changed

+43
-111
lines changed

9 files changed

+43
-111
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
.DS_Store
22
node_modules/
3-
dist/
43
npm-debug.log
54
test/unit/coverage
65
test/e2e/reports

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ $ npm install vue-button
2020
</template>
2121

2222
<script>
23-
import vButton from 'vue-button'
23+
import VueButton from 'vue-button'
2424
export default {
2525
components: {
26-
vButton
26+
VueButton
2727
}
2828
}
2929
</script>

build/build.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ spinner.start()
2121
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
2222
rm('-rf', assetsPath)
2323
mkdir('-p', assetsPath)
24-
cp('-R', 'static/*', assetsPath)
2524

2625
webpack(webpackConfig, function (err, stats) {
2726
spinner.stop()

build/webpack.prod.conf.js

Lines changed: 27 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,32 @@
1-
var path = require('path')
2-
var config = require('../config')
3-
var utils = require('./utils')
4-
var webpack = require('webpack')
5-
var merge = require('webpack-merge')
6-
var baseWebpackConfig = require('./webpack.base.conf')
7-
var ExtractTextPlugin = require('extract-text-webpack-plugin')
8-
var HtmlWebpackPlugin = require('html-webpack-plugin')
9-
var env = process.env.NODE_ENV === 'testing'
10-
? require('../config/test.env')
11-
: config.build.env
1+
const webpack = require('webpack')
2+
const base = require('./webpack.base.conf')
3+
const config = require('../config')
124

13-
var webpackConfig = merge(baseWebpackConfig, {
14-
module: {
15-
loaders: utils.styleLoaders({ sourceMap: config.build.productionSourceMap, extract: true })
16-
},
17-
devtool: config.build.productionSourceMap ? '#source-map' : false,
18-
output: {
19-
path: config.build.assetsRoot,
20-
filename: utils.assetsPath('js/[name].[chunkhash].js'),
21-
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
22-
},
23-
vue: {
24-
loaders: utils.cssLoaders({
25-
sourceMap: config.build.productionSourceMap,
26-
extract: true
27-
})
28-
},
29-
plugins: [
30-
// http://vuejs.github.io/vue-loader/en/workflow/production.html
31-
new webpack.DefinePlugin({
32-
'process.env': env
33-
}),
34-
new webpack.optimize.UglifyJsPlugin({
35-
compress: {
36-
warnings: false
37-
}
38-
}),
39-
new webpack.optimize.OccurrenceOrderPlugin(),
40-
// extract css into its own file
41-
new ExtractTextPlugin(utils.assetsPath('css/[name].[contenthash].css')),
42-
// generate dist index.html with correct asset hash for caching.
43-
// you can customize output by editing /index.html
44-
// see https://github.com/ampedandwired/html-webpack-plugin
45-
new HtmlWebpackPlugin({
46-
filename: process.env.NODE_ENV === 'testing'
47-
? 'index.html'
48-
: config.build.index,
49-
template: 'index.html',
50-
inject: true,
51-
minify: {
52-
removeComments: true,
53-
collapseWhitespace: true,
54-
removeAttributeQuotes: true
55-
// more options:
56-
// https://github.com/kangax/html-minifier#options-quick-reference
57-
},
58-
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
59-
chunksSortMode: 'dependency'
60-
}),
61-
// split vendor js into its own file
62-
new webpack.optimize.CommonsChunkPlugin({
63-
name: 'vendor',
64-
minChunks: function (module, count) {
65-
// any required modules inside node_modules are extracted to vendor
66-
return (
67-
module.resource &&
68-
/\.js$/.test(module.resource) &&
69-
module.resource.indexOf(
70-
path.join(__dirname, '../node_modules')
71-
) === 0
72-
)
73-
}
74-
}),
75-
// extract webpack runtime and module manifest to its own file in order to
76-
// prevent vendor hash from being updated whenever app bundle is updated
77-
new webpack.optimize.CommonsChunkPlugin({
78-
name: 'manifest',
79-
chunks: ['vendor']
80-
})
81-
]
82-
})
83-
84-
if (config.build.productionGzip) {
85-
var CompressionWebpackPlugin = require('compression-webpack-plugin')
5+
base.entry = {
6+
lib: './src/main.js'
7+
}
868

87-
webpackConfig.plugins.push(
88-
new CompressionWebpackPlugin({
89-
asset: '[path].gz[query]',
90-
algorithm: 'gzip',
91-
test: new RegExp(
92-
'\\.(' +
93-
config.build.productionGzipExtensions.join('|') +
94-
')$'
95-
),
96-
threshold: 10240,
97-
minRatio: 0.8
98-
})
99-
)
9+
base.output = {
10+
path: config.build.assetsRoot,
11+
publicPath: config.build.assetsPublicPath,
12+
filename: 'vue-button.js',
13+
library: 'VueButton',
14+
libraryTarget: 'umd'
10015
}
10116

17+
var webpackConfig = Object.assign({}, base)
18+
19+
webpackConfig.devtool = '#source-map'
20+
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
21+
new webpack.DefinePlugin({
22+
'process.env': {
23+
NODE_ENV: '"production"'
24+
}
25+
}),
26+
new webpack.optimize.UglifyJsPlugin({
27+
compress: { warnings: false }
28+
}),
29+
new webpack.optimize.OccurenceOrderPlugin(),
30+
])
31+
10232
module.exports = webpackConfig

dist/vue-button.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-button.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-button",
3-
"version": "0.0.3",
3+
"version": "0.0.10",
44
"description": "Button component for Vue.js",
55
"author": "steven5538 <steven5538@gmail.com>",
66
"keywords": [
@@ -30,9 +30,8 @@
3030
"test": "npm run unit && npm run e2e",
3131
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
3232
},
33+
"main": "./dist/vue-button.js",
3334
"dependencies": {
34-
"node-sass": "^3.13.0",
35-
"sass-loader": "^4.0.2",
3635
"vue": "^2.0.1"
3736
},
3837
"devDependencies": {
@@ -92,7 +91,9 @@
9291
"webpack": "^1.13.2",
9392
"webpack-dev-middleware": "^1.8.3",
9493
"webpack-hot-middleware": "^2.12.2",
95-
"webpack-merge": "^0.14.1"
94+
"webpack-merge": "^0.14.1",
95+
"node-sass": "^3.13.0",
96+
"sass-loader": "^4.0.2"
9697
},
9798
"engines": {
9899
"node": ">= 4.0.0",

src/dev.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue'
2-
import vButton from './components/Button.vue'
2+
import VueButton from './components/Button.vue'
33

4-
Vue.component('v-button', vButton)
4+
Vue.component('v-button', VueButton)
55

66
Vue.config.debug = true
77
Vue.config.devtools = true
@@ -10,5 +10,5 @@ Vue.config.devtools = true
1010
new Vue({
1111
el: '#app',
1212
template: '<v-button>Hello</v-button>',
13-
components: { vButton }
13+
components: { VueButton }
1414
})

src/main.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import vButton from './components/Button.vue'
1+
import VueButton from './components/Button.vue'
22

3-
export default vButton
4-
export { vButton }
3+
export default VueButton
4+
export { VueButton }

0 commit comments

Comments
 (0)