Commit 698c96f3 by golton_gao

update: 构建优化

parent 5d62fb76
......@@ -10,18 +10,6 @@ var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')
// 设置package.json的name与version跟随config.xml里配置 @add by evanxu 2017-06-29
// 改变package版本号
var fs = require('fs')
var xml2js = require('xml2js')
var parser = new xml2js.Parser({explicitArray: false})
var versiony = require('versiony')
var xml = fs.readFileSync(process.cwd() + '/config.xml', {encoding: 'utf-8'}).toString()
parser.parseString(xml, (err, result) => {
if (err) throw err
versiony.version(result.widget.$.version).major().to('package.json')
})
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
......
......@@ -10,18 +10,6 @@ var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prov.conf')
// 设置package.json的name与version跟随config.xml里配置 @add by evanxu 2017-06-29
// 改变package版本号
var fs = require('fs')
var xml2js = require('xml2js')
var parser = new xml2js.Parser({explicitArray: false})
var versiony = require('versiony')
var xml = fs.readFileSync(process.cwd() + '/config.xml', {encoding: 'utf-8'}).toString()
parser.parseString(xml, (err, result) => {
if (err) throw err
versiony.version(result.widget.$.version).major().to('package.json')
})
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
......
......@@ -37,10 +37,6 @@ const webpackConfig = {
formatter: require('eslint-friendly-formatter')
}
},
// {
// test: /\.less$/,
// loader: 'style-loader!css-loader!less-loader'
// },
{
test: /\.vue$/,
loader: 'vue-loader',
......
......@@ -6,23 +6,6 @@ var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
// 设置package.json的name与version跟随config.xml里配置 @add by evanxu 2017-06-29
// 设置版本号、时间
var exdate = require('exdate')
var fs = require('fs')
var xml2js = require('xml2js')
var parser = new xml2js.Parser({explicitArray: false})
var xml = fs.readFileSync(process.cwd() + '/config.xml', {encoding: 'utf-8'}).toString()
var versions;
parser.parseString(xml, (err, result) => {
if (err) {
throw err
}
versions = result.widget.$.version
})
var ds = new Date()
var dates = exdate.format(ds, 'yyyy-MM-dd HH:mm')
// add hot-reload related code to entry chunks
Object.keys(baseWebpackConfig.entry).forEach(function (name) {
baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name])
......@@ -36,9 +19,7 @@ module.exports = merge(baseWebpackConfig, {
devtool: '#cheap-module-eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env,
'process.vers': JSON.stringify(versions),
'process.dates': JSON.stringify(dates)
'process.env': config.dev.env
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.HotModuleReplacementPlugin(),
......
......@@ -9,23 +9,6 @@ var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
// 设置package.json的name与version跟随config.xml里配置 @add by evanxu 2017-06-29
// 设置版本号、时间
var exdate = require('exdate')
var fs = require('fs')
var xml2js = require('xml2js')
var parser = new xml2js.Parser({explicitArray: false})
var xml = fs.readFileSync(process.cwd() + '/config.xml', {encoding: 'utf-8'}).toString()
var versions;
parser.parseString(xml, (err, result) => {
if (err) {
throw err
}
versions = result.widget.$.version
})
var ds = new Date()
var dates = exdate.format(ds, 'yyyy-MM-dd HH:mm')
var env = config.build.env
var webpackConfig = merge(baseWebpackConfig, {
......@@ -44,9 +27,7 @@ var webpackConfig = merge(baseWebpackConfig, {
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env,
'process.vers': JSON.stringify(versions),
'process.dates': JSON.stringify(dates)
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
......
......@@ -10,22 +10,6 @@ var ExtractTextPlugin = require('extract-text-webpack-plugin')
var ZipPlugin = require('zip-webpack-plugin')
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
// 设置版本号、时间
var exdate = require('exdate')
var fs = require('fs')
var xml2js = require('xml2js')
var parser = new xml2js.Parser({explicitArray: false})
var xml = fs.readFileSync(process.cwd() + '/config.xml', {encoding: 'utf-8'}).toString()
var versions;
parser.parseString(xml, (err, result) => {
if (err) {
throw err
}
versions = result.widget.$.version
})
var ds = new Date()
var dates = exdate.format(ds, 'yyyy-MM-dd HH:mm')
var env = config.prov.env
var webpackConfig = merge(baseWebpackConfig, {
......@@ -44,9 +28,7 @@ var webpackConfig = merge(baseWebpackConfig, {
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env,
'process.vers': JSON.stringify(versions),
'process.dates': JSON.stringify(dates)
'process.env': env
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
......
......@@ -7,7 +7,7 @@ module.exports = {
index: path.resolve(__dirname, '../www/index.html'),
assetsRoot: path.resolve(__dirname, '../www'),
assetsSubDirectory: 'static',
assetsPublicPath: '',
assetsPublicPath: '/',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
......@@ -41,7 +41,7 @@ module.exports = {
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '',
assetsPublicPath: '/',
productionSourceMap: false,
appConfFile: 'CubeModule.json',
eslint: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment