Faster dev builds
Former-commit-id: 5e71565bcf0898f9f6e39ef2c81d36e8f233c6cf [formerly f457fc58ed639bf772b2b6a2c2193da0b64426f1] [formerly 3f7e5d9ed180d44b55634eb256da03ec368c6527 [formerly 4132ddf806
]]
Former-commit-id: 07bfec69fcf62facd7103ec0add4c54f3f92b4bc [formerly 352b0db0c60a8314b758dd9d1b925c36cd1ff381]
Former-commit-id: cf2ab3f5eb95279b033451dd7e2795055ab210f2
pull/726/head
parent
2d528a6a4e
commit
a3bafdc3e0
|
@ -2,8 +2,6 @@ var path = require('path')
|
|||
var utils = require('./utils')
|
||||
var config = require('./config')
|
||||
var vueLoaderConfig = require('./vue-loader.conf')
|
||||
var CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
var UglifyJS = require('uglify-js')
|
||||
|
||||
function resolve (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 ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
|
||||
var CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||
|
||||
module.exports = merge(baseWebpackConfig, {
|
||||
watch: true,
|
||||
|
@ -64,6 +65,17 @@ module.exports = merge(baseWebpackConfig, {
|
|||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'manifest',
|
||||
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 OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
|
||||
var SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin')
|
||||
var UglifyJS = require('uglify-js')
|
||||
|
||||
var env = config.build.env
|
||||
|
||||
|
@ -27,6 +28,24 @@ var webpackConfig = merge(baseWebpackConfig, {
|
|||
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
|
||||
},
|
||||
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
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': env
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Most of the code from this file comes from:
|
||||
// https://github.com/codemirror/CodeMirror/blob/master/addon/mode/loadmode.js
|
||||
import * as CodeMirror from 'codemirror'
|
||||
import store from '@/store/store'
|
||||
|
||||
// Make CodeMirror available globally so the modes' can register themselves.
|
||||
window.CodeMirror = CodeMirror
|
||||
|
||||
if (!CodeMirror.modeURL) CodeMirror.modeURL = '../mode/%N/%N.js'
|
||||
CodeMirror.modeURL = store.state.baseURL + '/static/js/codemirror/mode/%N/%N.js'
|
||||
|
||||
var loading = {}
|
||||
|
||||
|
|
|
@ -27,18 +27,22 @@ export default {
|
|||
}
|
||||
},
|
||||
mounted: function () {
|
||||
CodeMirror.modeURL = this.$store.state.baseURL + '/static/js/codemirror/mode/%N/%N.js'
|
||||
|
||||
this.content = CodeMirror.fromTextArea(document.getElementById('content'), {
|
||||
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'), {
|
||||
viewportMargin: Infinity
|
||||
})
|
||||
|
||||
CodeMirror.autoLoadMode(this.content, this.req.language)
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue