Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge repo mine #4

Merged
merged 3 commits into from
Jan 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions frontend/vue.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = webpackConfig => {
webpackConfig.plugin('html').tap(([options]) => [
Object.assign(options, {
publicPath: './',
minify: {
removeComments: true, // 是否去掉注释
removeCommentsFromCDATA: true, // 移除来自字符数据的注释
collapseWhitespace: true, // 是否去掉空格
conservativeCollapse: false, // 删除空格,总是保留一个空格
collapseInlineTagWhitespace: true, // 去除内联标签中的空格
collapseBooleanAttributes: true, // 简化布尔属性
removeRedundantAttributes: true, // 删除多余的属性
removeAttributeQuotes: false, // 是否移除属性引号
removeEmptyAttributes: true, // 移除空属性
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true,
minifyJS: true, // 是否压缩html里的js
minifyCSS: true // 是否压缩html里的css
},
inject: true,
chunksSortMode: 'none'
})
])
}
50 changes: 50 additions & 0 deletions frontend/vue.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const VUE_SERVE = require('./vue.serve')
const VUE_BUILD = require('./vue.build')

module.exports = {
lintOnSave: true,
css: {
extract: false,
sourceMap: process.env.NODE_ENV === 'production' ? false : true,
loaderOptions: {}
},
devServer: {
open: true,
host: '0.0.0.0',
port: 8899,
https: false,
hotOnly: false,
proxy: null
},
productionSourceMap: process.env.NODE_ENV === 'production' ? false : true,
chainWebpack: webpackConfig => {
webpackConfig.module
.rule('images')
.test(/\.(png|jpe?g|gif|webp)(\?.*)?$/)
.use('url-loader')
.loader('url-loader')
.options({
limit: 10000,
name: 'image/[name].[hash:8].[ext]'
})
webpackConfig.module
.rule('js')
.test(/\.js$/)
.use('babel-loader')
.loader('babel-loader')
webpackConfig.module
.rule('js')
.test(/\.exec\.js$/)
.use('script-loader')
.loader('script-loader')
webpackConfig.module
.rule('svg')
.test(/\.(svg)(\?.*)?$/)
.use('file-loader')
.loader('file-loader')
.options({
name: 'image/[name].[hash:8].[ext]'
})
process.env.NODE_ENV === 'production' ? VUE_BUILD(webpackConfig) : VUE_SERVE(webpackConfig)
}
}
9 changes: 9 additions & 0 deletions frontend/vue.serve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = webpackConfig => {
webpackConfig.plugin('html').tap(([options]) => [
Object.assign(options, {
minify: false,
inject: true,
chunksSortMode: 'none'
})
])
}