Skip to content

Commit 872ebef

Browse files
committed
发布0.0.1版本
1 parent 26ba015 commit 872ebef

10 files changed

+98
-137
lines changed

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
22
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
33
electron_mirror=https://npm.taobao.org/mirrors/electron/
44
chromedriver_cdnurl=https://npm.taobao.org/mirrors/chromedriver
5-
registry=https://registry.npm.taobao.org
5+
//registry=https://registry.npm.taobao.org

build/utils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ exports.cssLoaders = function (options) {
4444

4545
// Extract CSS when that option is specified
4646
// (which is the case during production build)
47-
if (options.extract) {
48-
return ExtractTextPlugin.extract({
49-
use: loaders,
50-
fallback: 'vue-style-loader'
51-
})
52-
} else {
47+
// if (options.extract) {
48+
// return ExtractTextPlugin.extract({
49+
// use: loaders,
50+
// fallback: 'vue-style-loader'
51+
// })
52+
// } else {
5353
return ['vue-style-loader'].concat(loaders)
54-
}
54+
// }
5555
}
5656

5757
// https://vue-loader.vuejs.org/en/configurations/extract-css.html

build/vue-loader.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
cssSourceMap: sourceMapEnabled,
1515
cacheBusting: config.dev.cacheBusting,
1616
transformToRequire: {
17-
video: ['src', 'poster'],
17+
video: 'src',
1818
source: 'src',
1919
img: 'src',
2020
image: 'xlink:href'

build/webpack.base.conf.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ const createLintingRule = () => ({
1414
enforce: 'pre',
1515
include: [resolve('src'), resolve('test')],
1616
options: {
17-
formatter: require('eslint-friendly-formatter'),
18-
emitWarning: !config.dev.showEslintErrorsInOverlay
17+
formatter: require('eslint-friendly-formatter')
1918
}
2019
})
2120

2221
module.exports = {
2322
context: path.resolve(__dirname, '../'),
2423
entry: {
25-
app: './src/main.js'
24+
app: ['babel-polyfill', './src/main.js']
2625
},
2726
output: {
2827
path: config.build.assetsRoot,
@@ -49,7 +48,7 @@ module.exports = {
4948
{
5049
test: /\.js$/,
5150
loader: 'babel-loader',
52-
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
51+
include: [resolve('src'), resolve('test')]
5352
},
5453
{
5554
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

build/webpack.prod.conf.js

Lines changed: 16 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -16,110 +16,38 @@ const env = process.env.NODE_ENV === 'testing'
1616
: require('../config/prod.env')
1717

1818
const webpackConfig = merge(baseWebpackConfig, {
19+
entry: {
20+
app:'./src/lib/index'
21+
},
1922
module: {
2023
rules: utils.styleLoaders({
2124
sourceMap: config.build.productionSourceMap,
22-
extract: true,
23-
usePostCSS: true
25+
extract: false
2426
})
2527
},
2628
devtool: config.build.productionSourceMap ? config.build.devtool : false,
2729
output: {
2830
path: config.build.assetsRoot,
29-
filename: utils.assetsPath('js/[name].[chunkhash].js'),
30-
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
31+
filename: 'vue-code-diff.js',
32+
library: 'vue-code-diff',
33+
libraryTarget: 'umd'
34+
},
35+
externals: {
36+
'diff': 'diff',
37+
'diff2html': 'diff2html',
38+
'highlight.js':'highlight.js',
39+
'vue': 'vue'
3140
},
3241
plugins: [
3342
// http://vuejs.github.io/vue-loader/en/workflow/production.html
3443
new webpack.DefinePlugin({
3544
'process.env': env
3645
}),
37-
new UglifyJsPlugin({
38-
uglifyOptions: {
46+
new webpack.optimize.UglifyJsPlugin({
3947
compress: {
4048
warnings: false
41-
}
42-
},
43-
sourceMap: config.build.productionSourceMap,
44-
parallel: true
45-
}),
46-
// extract css into its own file
47-
new ExtractTextPlugin({
48-
filename: utils.assetsPath('css/[name].[contenthash].css'),
49-
// Setting the following option to `false` will not extract CSS from codesplit chunks.
50-
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
51-
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
52-
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
53-
allChunks: true,
54-
}),
55-
// Compress extracted CSS. We are using this plugin so that possible
56-
// duplicated CSS from different components can be deduped.
57-
new OptimizeCSSPlugin({
58-
cssProcessorOptions: config.build.productionSourceMap
59-
? { safe: true, map: { inline: false } }
60-
: { safe: true }
61-
}),
62-
// generate dist index.html with correct asset hash for caching.
63-
// you can customize output by editing /index.html
64-
// see https://github.com/ampedandwired/html-webpack-plugin
65-
new HtmlWebpackPlugin({
66-
filename: process.env.NODE_ENV === 'testing'
67-
? 'index.html'
68-
: config.build.index,
69-
template: 'index.html',
70-
inject: true,
71-
minify: {
72-
removeComments: true,
73-
collapseWhitespace: true,
74-
removeAttributeQuotes: true
75-
// more options:
76-
// https://github.com/kangax/html-minifier#options-quick-reference
77-
},
78-
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
79-
chunksSortMode: 'dependency'
80-
}),
81-
// keep module.id stable when vendor modules does not change
82-
new webpack.HashedModuleIdsPlugin(),
83-
// enable scope hoisting
84-
new webpack.optimize.ModuleConcatenationPlugin(),
85-
// split vendor js into its own file
86-
new webpack.optimize.CommonsChunkPlugin({
87-
name: 'vendor',
88-
minChunks (module) {
89-
// any required modules inside node_modules are extracted to vendor
90-
return (
91-
module.resource &&
92-
/\.js$/.test(module.resource) &&
93-
module.resource.indexOf(
94-
path.join(__dirname, '../node_modules')
95-
) === 0
96-
)
97-
}
98-
}),
99-
// extract webpack runtime and module manifest to its own file in order to
100-
// prevent vendor hash from being updated whenever app bundle is updated
101-
new webpack.optimize.CommonsChunkPlugin({
102-
name: 'manifest',
103-
minChunks: Infinity
104-
}),
105-
// This instance extracts shared chunks from code splitted chunks and bundles them
106-
// in a separate chunk, similar to the vendor chunk
107-
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
108-
new webpack.optimize.CommonsChunkPlugin({
109-
name: 'app',
110-
async: 'vendor-async',
111-
children: true,
112-
minChunks: 3
113-
}),
114-
115-
// copy custom static assets
116-
new CopyWebpackPlugin([
117-
{
118-
from: path.resolve(__dirname, '../static'),
119-
to: config.build.assetsSubDirectory,
120-
ignore: ['.*']
121-
}
122-
])
49+
},
50+
sourceMap: false})
12351
]
12452
})
12553

package.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
{
22
"name": "vue-code-diff",
3-
"version": "1.0.0",
4-
"description": "A Vue.js project",
5-
"author": "ddchef <o.o@xjie.me>",
6-
"private": true,
3+
"version": "0.0.1",
4+
"description": "代码比对展示(Code comparison display)",
5+
"author": "ddchef>",
6+
"private": false,
7+
"main": "/dist/vue-code-diff.js",
8+
"keywords":[
9+
"vue",
10+
"diff",
11+
"code"
12+
],
13+
"repository":{
14+
"type": "git",
15+
"url": "git+https://github.com/ddchef/vue-code-diff.git"
16+
},
717
"scripts": {
818
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
919
"start": "npm run dev",
@@ -29,6 +39,7 @@
2939
"babel-plugin-syntax-jsx": "^6.18.0",
3040
"babel-plugin-transform-runtime": "^6.22.0",
3141
"babel-plugin-transform-vue-jsx": "^3.5.0",
42+
"babel-polyfill": "^6.26.0",
3243
"babel-preset-env": "^1.3.2",
3344
"babel-preset-stage-2": "^6.22.0",
3445
"babel-register": "^6.22.0",

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66

77
<script>
8-
import codeDiff from './lib'
8+
import codeDiff from '../dist/vue-code-diff'
99
import oldStr from './date/oldStr'
1010
import newStr from './date/newStr'
1111
export default {

src/date/newStr.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
export default `
2-
<html>
2+
'use strict'
3+
const utils = require('./utils')
4+
const config = require('../config')
5+
const isProduction = process.env.NODE_ENV === 'production'
6+
const sourceMapEnabled = isProduction
7+
? config.build.productionSourceMap
8+
: config.dev.cssSourceMap
39
4-
<head>
5-
<script type="text/javascript" src="loadxmldoc.js">
6-
</script>
7-
</head>
8-
9-
<body>
10-
11-
<script type="text/javascript">
12-
xmlDoc=loadXMLDoc("books.xml");
13-
document.write("xmlDoc is loaded, ready for use");
14-
</script>
15-
16-
</body>
17-
18-
</html>
10+
module.exports = {
11+
loaders: utils.cssLoaders({
12+
sourceMap: sourceMapEnabled,
13+
extract: isProduction
14+
}),
15+
cssSourceMap: sourceMapEnabled,
16+
cacheBusting: config.dev.cacheBusting,
17+
transformToRequire: {
18+
video: 'src',
19+
source: 'src',
20+
img: 'src',
21+
image: 'xlink:href'
22+
}
23+
}
1924
`

src/date/oldStr.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
export default `
2-
<html>
2+
'use strict'
3+
const utils = require('./utils')
4+
const config = require('../config')
5+
const isProduction = process.env.NODE_ENV === 'production'
6+
const sourceMapEnabled = isProduction
7+
? config.build.productionSourceMap
8+
: config.dev.cssSourceMap
39
4-
<head>
5-
<script type="text/javascript" src="loadxmldoc.js">
6-
</script>
7-
</head>
8-
9-
<body>
10-
<script type="text/javascript">
11-
xmlDoc=loadXMLDoc("books.xml");
12-
document.write("xmlDoc is loaded, ready for use");
13-
</script>
14-
15-
</body>
16-
17-
</html>
10+
module.exports = {
11+
loaders: utils.cssLoaders({
12+
sourceMap: sourceMapEnabled,
13+
extract: isProductionSSSS
14+
}),
15+
cssSourceMap: sourceMapEnabled,
16+
cacheBusting: config.dev.cacheBusting,
17+
transformToRequire: {
18+
video: 'src',
19+
source: 'src',
20+
img: 'src',
21+
image: 'xlink:href'
22+
}
23+
}
1824
`

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,14 @@ babel-plugin-transform-vue-jsx@^3.5.0:
887887
dependencies:
888888
esutils "^2.0.2"
889889

890+
babel-polyfill@^6.26.0:
891+
version "6.26.0"
892+
resolved "http://registry.npm.taobao.org/babel-polyfill/download/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
893+
dependencies:
894+
babel-runtime "^6.26.0"
895+
core-js "^2.5.0"
896+
regenerator-runtime "^0.10.5"
897+
890898
babel-preset-env@^1.3.2:
891899
version "1.6.1"
892900
resolved "http://registry.npm.taobao.org/babel-preset-env/download/babel-preset-env-1.6.1.tgz#a18b564cc9b9afdf4aae57ae3c1b0d99188e6f48"
@@ -6099,6 +6107,10 @@ regenerate@^1.2.1:
60996107
version "1.3.3"
61006108
resolved "http://registry.npm.taobao.org/regenerate/download/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f"
61016109

6110+
regenerator-runtime@^0.10.5:
6111+
version "0.10.5"
6112+
resolved "http://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
6113+
61026114
regenerator-runtime@^0.11.0:
61036115
version "0.11.1"
61046116
resolved "http://registry.npm.taobao.org/regenerator-runtime/download/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"

0 commit comments

Comments
 (0)