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>
</div>
</body>
<script src="/dist/build.js"></script>
</html>

View File

@ -1,93 +1,96 @@
{
"name": "vue-ant-design",
"version": "1.0.0",
"description": "vue component",
"main": "index.js",
"scripts": {
"start": "NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot",
"test": "karma start test/karma.conf.js --single-run",
"lint": "eslint -c ./.eslintrc --fix --ext .js ./src/",
"lint:style": "stylelint \"./src/**/*.less\" --syntax less"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vueComponent/ant-design.git"
},
"keywords": [
"vue"
],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/vueComponent/ant-design/issues"
},
"homepage": "https://github.com/vueComponent/ant-design#readme",
"pre-commit": [
"lint",
"lint:style"
],
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-helper-vue-jsx-merge-props": "^2.0.2",
"babel-loader": "^7.1.2",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"chai": "^4.1.2",
"css-loader": "^0.28.7",
"eslint": "^4.7.2",
"eslint-plugin-html": "^3.2.2",
"eslint-plugin-vue-libs": "^1.2.1",
"html-webpack-plugin": "^2.30.1",
"istanbul-instrumenter-loader": "^3.0.0",
"karma": "^1.4.1",
"karma-coverage": "^1.1.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "^1.3.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.2",
"less": "^2.7.2",
"less-loader": "^4.0.5",
"marked": "^0.3.7",
"mocha": "^3.2.0",
"pre-commit": "^1.2.2",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"sinon": "^4.0.2",
"sinon-chai": "^2.8.0",
"style-loader": "^0.18.2",
"stylelint": "^8.1.1",
"stylelint-config-standard": "^17.0.0",
"vue-loader": "^13.0.5",
"vue-router": "^3.0.1",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.8.2"
},
"dependencies": {
"add-dom-event-listener": "^1.0.2",
"css-animation": "^1.4.1",
"dom-align": "^1.6.7",
"dom-scroll-into-view": "^1.2.1",
"eslint-plugin-vue": "^3.13.0",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"lodash.isplainobject": "^4.0.6",
"omit.js": "^1.0.0",
"vue": "^2.5.13",
"vue-types": "^1.0.2",
"warning": "^3.0.0"
}
"name": "vue-ant-design",
"version": "1.0.0",
"description": "vue component",
"main": "index.js",
"scripts": {
"start": "NODE_ENV=development ./node_modules/.bin/webpack-dev-server --open --hot",
"test": "karma start test/karma.conf.js --single-run",
"build": "sh build.sh",
"lint": "eslint -c ./.eslintrc --fix --ext .js ./src/",
"lint:style": "stylelint \"./src/**/*.less\" --syntax less"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vueComponent/ant-design.git"
},
"keywords": [
"vue"
],
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/vueComponent/ant-design/issues"
},
"homepage": "https://github.com/vueComponent/ant-design#readme",
"pre-commit": [
"lint",
"lint:style"
],
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-helper-vue-jsx-merge-props": "^2.0.2",
"babel-loader": "^7.1.2",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"chai": "^4.1.2",
"css-loader": "^0.28.7",
"eslint": "^4.7.2",
"eslint-plugin-html": "^3.2.2",
"eslint-plugin-vue-libs": "^1.2.1",
"extract-text-webpack-plugin": "^3.0.2",
"html-webpack-plugin": "^2.30.1",
"istanbul-instrumenter-loader": "^3.0.0",
"karma": "^1.4.1",
"karma-coverage": "^1.1.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "^1.3.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.2",
"less": "^2.7.2",
"less-loader": "^4.0.5",
"marked": "^0.3.7",
"mocha": "^3.2.0",
"pre-commit": "^1.2.2",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"sinon": "^4.0.2",
"sinon-chai": "^2.8.0",
"style-loader": "^0.18.2",
"stylelint": "^8.1.1",
"stylelint-config-standard": "^17.0.0",
"vue-loader": "^13.0.5",
"vue-router": "^3.0.1",
"vue-template-compiler": "^2.5.13",
"webpack": "^3.6.0",
"webpack-chunk-hash": "^0.5.0",
"webpack-dev-server": "^2.8.2"
},
"dependencies": {
"add-dom-event-listener": "^1.0.2",
"css-animation": "^1.4.1",
"dom-align": "^1.6.7",
"dom-scroll-into-view": "^1.2.1",
"eslint-plugin-vue": "^3.13.0",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"lodash.isequal": "^4.5.0",
"lodash.isplainobject": "^4.0.6",
"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 webpack = require('webpack')
// const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
entry: {
@ -9,7 +10,7 @@ module.exports = {
},
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
publicPath: '/',
filename: 'build.js',
},
module: {
@ -53,9 +54,10 @@ module.exports = {
},
devServer: {
port: 3000,
inline: true,
historyApiFallback: {
index: 'examples/index.html',
rewrites: [
{ from: /.*/, to: '/index.html' },
],
},
disableHostCheck: true,
headers: { 'Access-Control-Allow-Origin': '*' },
@ -66,23 +68,10 @@ module.exports = {
devtool: '#source-map',
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// 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.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false,
},
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
}),
])
}
module.exports.plugins = (module.exports.plugins || []).concat([
new HtmlWebpackPlugin({
template: 'examples/index.html',
filename: 'index.html',
inject: 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' }),
])