Faster dev builds
Former-commit-id: 5e71565bcf0898f9f6e39ef2c81d36e8f233c6cf [formerly f457fc58ed639bf772b2b6a2c2193da0b64426f1] [formerly 3f7e5d9ed180d44b55634eb256da03ec368c6527 [formerly 4132ddf80628cfa19b1b6ab71e5ba222eb4306bb]] Former-commit-id: 07bfec69fcf62facd7103ec0add4c54f3f92b4bc [formerly 352b0db0c60a8314b758dd9d1b925c36cd1ff381] Former-commit-id: cf2ab3f5eb95279b033451dd7e2795055ab210f2
This commit is contained in:
parent
2d528a6a4e
commit
a3bafdc3e0
|
@ -2,8 +2,6 @@ var path = require('path')
|
||||||
var utils = require('./utils')
|
var utils = require('./utils')
|
||||||
var config = require('./config')
|
var config = require('./config')
|
||||||
var vueLoaderConfig = require('./vue-loader.conf')
|
var vueLoaderConfig = require('./vue-loader.conf')
|
||||||
var CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
||||||
var UglifyJS = require('uglify-js')
|
|
||||||
|
|
||||||
function resolve (dir) {
|
function resolve (dir) {
|
||||||
return path.join(__dirname, '..', dir)
|
return path.join(__dirname, '..', dir)
|
||||||
|
@ -65,25 +63,5 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
plugins: [
|
|
||||||
new CopyWebpackPlugin([
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, '../static'),
|
|
||||||
to: config.dev.assetsSubDirectory,
|
|
||||||
ignore: ['.*']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
|
|
||||||
to: path.join(config.build.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js'),
|
|
||||||
transform: function (source, path) {
|
|
||||||
let result = UglifyJS.minify(source.toString('utf8'))
|
|
||||||
if (result.error !== undefined) {
|
|
||||||
return source
|
|
||||||
}
|
|
||||||
return result.code
|
|
||||||
}
|
|
||||||
}
|
|
||||||
])
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ var baseWebpackConfig = require('./webpack.base.conf')
|
||||||
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
||||||
|
var CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||||
|
|
||||||
module.exports = merge(baseWebpackConfig, {
|
module.exports = merge(baseWebpackConfig, {
|
||||||
watch: true,
|
watch: true,
|
||||||
|
@ -64,6 +65,17 @@ module.exports = merge(baseWebpackConfig, {
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new webpack.optimize.CommonsChunkPlugin({
|
||||||
name: 'manifest',
|
name: 'manifest',
|
||||||
chunks: ['vendor']
|
chunks: ['vendor']
|
||||||
})
|
}),
|
||||||
|
new CopyWebpackPlugin([
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../static'),
|
||||||
|
to: config.dev.assetsSubDirectory,
|
||||||
|
ignore: ['.*']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
|
||||||
|
to: path.join(config.build.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js')
|
||||||
|
}
|
||||||
|
])
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,6 +10,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
var ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
var OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
||||||
var SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin')
|
var SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin')
|
||||||
|
var UglifyJS = require('uglify-js')
|
||||||
|
|
||||||
var env = config.build.env
|
var env = config.build.env
|
||||||
|
|
||||||
|
@ -27,6 +28,24 @@ var webpackConfig = merge(baseWebpackConfig, {
|
||||||
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
new CopyWebpackPlugin([
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../static'),
|
||||||
|
to: config.dev.assetsSubDirectory,
|
||||||
|
ignore: ['.*']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
from: path.resolve(__dirname, '../node_modules/codemirror/mode/*/*'),
|
||||||
|
to: path.join(config.build.assetsSubDirectory, 'js/codemirror/mode/[name]/[name].js'),
|
||||||
|
transform: function (source, path) {
|
||||||
|
let result = UglifyJS.minify(source.toString('utf8'))
|
||||||
|
if (result.error !== undefined) {
|
||||||
|
return source
|
||||||
|
}
|
||||||
|
return result.code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
'process.env': env
|
'process.env': env
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// Most of the code from this file comes from:
|
// Most of the code from this file comes from:
|
||||||
// https://github.com/codemirror/CodeMirror/blob/master/addon/mode/loadmode.js
|
// https://github.com/codemirror/CodeMirror/blob/master/addon/mode/loadmode.js
|
||||||
import * as CodeMirror from 'codemirror'
|
import * as CodeMirror from 'codemirror'
|
||||||
|
import store from '@/store/store'
|
||||||
|
|
||||||
// Make CodeMirror available globally so the modes' can register themselves.
|
// Make CodeMirror available globally so the modes' can register themselves.
|
||||||
window.CodeMirror = CodeMirror
|
window.CodeMirror = CodeMirror
|
||||||
|
CodeMirror.modeURL = store.state.baseURL + '/static/js/codemirror/mode/%N/%N.js'
|
||||||
if (!CodeMirror.modeURL) CodeMirror.modeURL = '../mode/%N/%N.js'
|
|
||||||
|
|
||||||
var loading = {}
|
var loading = {}
|
||||||
|
|
||||||
|
|
|
@ -27,18 +27,22 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
CodeMirror.modeURL = this.$store.state.baseURL + '/static/js/codemirror/mode/%N/%N.js'
|
|
||||||
|
|
||||||
this.content = CodeMirror.fromTextArea(document.getElementById('content'), {
|
this.content = CodeMirror.fromTextArea(document.getElementById('content'), {
|
||||||
lineNumbers: (this.req.language !== 'markdown'),
|
lineNumbers: (this.req.language !== 'markdown'),
|
||||||
viewportMargin: Infinity
|
viewportMargin: Infinity,
|
||||||
|
autofocus: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
CodeMirror.autoLoadMode(this.content, this.req.language)
|
||||||
|
|
||||||
|
// Prevent of going on if there is no metadata.
|
||||||
|
if (!this.hasMetadata) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.metadata = CodeMirror.fromTextArea(document.getElementById('metadata'), {
|
this.metadata = CodeMirror.fromTextArea(document.getElementById('metadata'), {
|
||||||
viewportMargin: Infinity
|
viewportMargin: Infinity
|
||||||
})
|
})
|
||||||
|
|
||||||
CodeMirror.autoLoadMode(this.content, this.req.language)
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue