build site

This commit is contained in:
tangjinzhou 2018-01-22 15:47:22 +08:00
parent 28866a8eca
commit f61c6a4cd3
5 changed files with 209 additions and 116 deletions

5
build.sh Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
rm -rf dist
mkdir dist
./node_modules/.bin/webpack --config webpack.prod.config.js
cp dist/index.html index.html

View File

@ -8,6 +8,5 @@
<router-view></router-view> <router-view></router-view>
</div> </div>
</body> </body>
<script src="/dist/build.js"></script>
</html> </html>

View File

@ -1,93 +1,96 @@
{ {
"name": "vue-ant-design", "name": "vue-ant-design",
"version": "1.0.0", "version": "1.0.0",
"description": "vue component", "description": "vue component",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot", "start": "NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot",
"test": "karma start test/karma.conf.js --single-run", "test": "karma start test/karma.conf.js --single-run",
"lint": "eslint -c ./.eslintrc --fix --ext .js ./src/", "build": "sh build.sh",
"lint:style": "stylelint \"./src/**/*.less\" --syntax less" "lint": "eslint -c ./.eslintrc --fix --ext .js ./src/",
}, "lint:style": "stylelint \"./src/**/*.less\" --syntax less"
"repository": { },
"type": "git", "repository": {
"url": "git+https://github.com/vueComponent/ant-design.git" "type": "git",
}, "url": "git+https://github.com/vueComponent/ant-design.git"
"keywords": [ },
"vue" "keywords": [
], "vue"
"author": "", ],
"license": "MIT", "author": "",
"bugs": { "license": "MIT",
"url": "https://github.com/vueComponent/ant-design/issues" "bugs": {
}, "url": "https://github.com/vueComponent/ant-design/issues"
"homepage": "https://github.com/vueComponent/ant-design#readme", },
"pre-commit": [ "homepage": "https://github.com/vueComponent/ant-design#readme",
"lint", "pre-commit": [
"lint:style" "lint",
], "lint:style"
"devDependencies": { ],
"babel-cli": "^6.26.0", "devDependencies": {
"babel-eslint": "^8.0.1", "babel-cli": "^6.26.0",
"babel-helper-vue-jsx-merge-props": "^2.0.2", "babel-eslint": "^8.0.1",
"babel-loader": "^7.1.2", "babel-helper-vue-jsx-merge-props": "^2.0.2",
"babel-plugin-istanbul": "^4.1.1", "babel-loader": "^7.1.2",
"babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-istanbul": "^4.1.1",
"babel-plugin-syntax-jsx": "^6.18.0", "babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-decorators": "^6.24.1", "babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-vue-jsx": "^3.5.0", "babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0", "babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.6.0", "babel-polyfill": "^6.26.0",
"chai": "^4.1.2", "babel-preset-env": "^1.6.0",
"css-loader": "^0.28.7", "chai": "^4.1.2",
"eslint": "^4.7.2", "css-loader": "^0.28.7",
"eslint-plugin-html": "^3.2.2", "eslint": "^4.7.2",
"eslint-plugin-vue-libs": "^1.2.1", "eslint-plugin-html": "^3.2.2",
"html-webpack-plugin": "^2.30.1", "eslint-plugin-vue-libs": "^1.2.1",
"istanbul-instrumenter-loader": "^3.0.0", "extract-text-webpack-plugin": "^3.0.2",
"karma": "^1.4.1", "html-webpack-plugin": "^2.30.1",
"karma-coverage": "^1.1.1", "istanbul-instrumenter-loader": "^3.0.0",
"karma-coverage-istanbul-reporter": "^1.3.0", "karma": "^1.4.1",
"karma-mocha": "^1.3.0", "karma-coverage": "^1.1.1",
"karma-phantomjs-launcher": "^1.0.2", "karma-coverage-istanbul-reporter": "^1.3.0",
"karma-phantomjs-shim": "^1.4.0", "karma-mocha": "^1.3.0",
"karma-sinon-chai": "^1.3.1", "karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7", "karma-phantomjs-shim": "^1.4.0",
"karma-spec-reporter": "0.0.31", "karma-sinon-chai": "^1.3.1",
"karma-webpack": "^2.0.2", "karma-sourcemap-loader": "^0.3.7",
"less": "^2.7.2", "karma-spec-reporter": "0.0.31",
"less-loader": "^4.0.5", "karma-webpack": "^2.0.2",
"marked": "^0.3.7", "less": "^2.7.2",
"mocha": "^3.2.0", "less-loader": "^4.0.5",
"pre-commit": "^1.2.2", "marked": "^0.3.7",
"selenium-server": "^3.0.1", "mocha": "^3.2.0",
"semver": "^5.3.0", "pre-commit": "^1.2.2",
"sinon": "^4.0.2", "selenium-server": "^3.0.1",
"sinon-chai": "^2.8.0", "semver": "^5.3.0",
"style-loader": "^0.18.2", "sinon": "^4.0.2",
"stylelint": "^8.1.1", "sinon-chai": "^2.8.0",
"stylelint-config-standard": "^17.0.0", "style-loader": "^0.18.2",
"vue-loader": "^13.0.5", "stylelint": "^8.1.1",
"vue-router": "^3.0.1", "stylelint-config-standard": "^17.0.0",
"vue-template-compiler": "^2.5.13", "vue-loader": "^13.0.5",
"webpack": "^3.6.0", "vue-router": "^3.0.1",
"webpack-dev-server": "^2.8.2" "vue-template-compiler": "^2.5.13",
}, "webpack": "^3.6.0",
"dependencies": { "webpack-chunk-hash": "^0.5.0",
"add-dom-event-listener": "^1.0.2", "webpack-dev-server": "^2.8.2"
"css-animation": "^1.4.1", },
"dom-align": "^1.6.7", "dependencies": {
"dom-scroll-into-view": "^1.2.1", "add-dom-event-listener": "^1.0.2",
"eslint-plugin-vue": "^3.13.0", "css-animation": "^1.4.1",
"lodash.clonedeep": "^4.5.0", "dom-align": "^1.6.7",
"lodash.debounce": "^4.0.8", "dom-scroll-into-view": "^1.2.1",
"lodash.isequal": "^4.5.0", "eslint-plugin-vue": "^3.13.0",
"lodash.isplainobject": "^4.0.6", "lodash.clonedeep": "^4.5.0",
"omit.js": "^1.0.0", "lodash.debounce": "^4.0.8",
"vue": "^2.5.13", "lodash.isequal": "^4.5.0",
"vue-types": "^1.0.2", "lodash.isplainobject": "^4.0.6",
"warning": "^3.0.0" "omit.js": "^1.0.0",
} "vue": "^2.5.13",
"vue-types": "^1.0.2",
"warning": "^3.0.0"
}
} }

View File

@ -1,5 +1,6 @@
const path = require('path') const path = require('path')
const webpack = require('webpack') // const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = { module.exports = {
entry: { entry: {
@ -9,7 +10,7 @@ module.exports = {
}, },
output: { output: {
path: path.resolve(__dirname, './dist'), path: path.resolve(__dirname, './dist'),
publicPath: '/dist/', publicPath: '/',
filename: 'build.js', filename: 'build.js',
}, },
module: { module: {
@ -53,9 +54,10 @@ module.exports = {
}, },
devServer: { devServer: {
port: 3000, port: 3000,
inline: true,
historyApiFallback: { historyApiFallback: {
index: 'examples/index.html', rewrites: [
{ from: /.*/, to: '/index.html' },
],
}, },
disableHostCheck: true, disableHostCheck: true,
headers: { 'Access-Control-Allow-Origin': '*' }, headers: { 'Access-Control-Allow-Origin': '*' },
@ -66,23 +68,10 @@ module.exports = {
devtool: '#source-map', devtool: '#source-map',
} }
if (process.env.NODE_ENV === 'production') { module.exports.plugins = (module.exports.plugins || []).concat([
module.exports.devtool = '#source-map' new HtmlWebpackPlugin({
// http://vue-loader.vuejs.org/en/workflow/production.html template: 'examples/index.html',
module.exports.plugins = (module.exports.plugins || []).concat([ filename: 'index.html',
new webpack.DefinePlugin({ inject: true,
'process.env': { }),
NODE_ENV: '"production"', ])
},
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false,
},
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
])
}

97
webpack.prod.config.js Normal file
View File

@ -0,0 +1,97 @@
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const WebpackChunkHash = require('webpack-chunk-hash')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const modulePlugin = new ExtractTextPlugin({
filename: '[name].[chunkhash].css',
allChunks: true,
})
module.exports = {
entry: {
index: [
'./examples/index.js',
],
},
output: {
path: path.resolve(__dirname, './dist'),
publicPath: './dist/',
filename: '[name].[chunkhash].js',
chunkFilename: '[chunkhash].async.js',
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.js$/,
loader: 'babel-loader', exclude: /node_modules/,
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]',
},
},
{
test: /\.less$/,
use: modulePlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
},
{ loader: 'less-loader',
},
],
}),
},
],
},
resolve: {
extensions: ['.js', '.vue'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'antd': path.join(__dirname, 'components'),
},
},
}
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"',
},
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vender',
minChunks: function (module) {
return module.context && ~module.context.indexOf('node_modules')
},
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
},
}),
new HtmlWebpackPlugin({
template: './examples/index.html',
inject: true,
minify: { collapseWhitespace: true },
production: true,
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
modulePlugin,
new WebpackChunkHash({ algorithm: 'md5' }),
])