Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56f67f0

Browse files
committed
perf[chore]: webpack
1 parent e504ae5 commit 56f67f0

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

build/webpack.base.conf.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const path = require('path')
33
const utils = require('./utils')
44
const config = require('../config')
55
const vueLoaderConfig = require('./vue-loader.conf')
6-
const CopyWebpackPlugin = require('copy-webpack-plugin')
76

87
function resolve (dir) {
98
return path.join(__dirname, '..', dir)
@@ -87,13 +86,6 @@ module.exports = {
8786
}
8887
]
8988
},
90-
plugins:[
91-
new CopyWebpackPlugin([
92-
{
93-
from: 'static/tinymce'
94-
}
95-
])
96-
],
9789
node: {
9890
// prevent webpack from injecting useless setImmediate polyfill because Vue
9991
// source contains it (although only uses it if it's native).

build/webpack.dev.conf.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict'
2-
const path = require('path')
32
const utils = require('./utils')
43
const webpack = require('webpack')
54
const config = require('../config')
65
const merge = require('webpack-merge')
6+
const path = require('path')
77
const baseWebpackConfig = require('./webpack.base.conf')
8+
const CopyWebpackPlugin = require('copy-webpack-plugin')
89
const HtmlWebpackPlugin = require('html-webpack-plugin')
910
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
1011
const portfinder = require('portfinder')
@@ -26,8 +27,13 @@ const devWebpackConfig = merge(baseWebpackConfig, {
2627
// these devServer options should be customized in /config/index.js
2728
devServer: {
2829
clientLogLevel: 'warning',
29-
historyApiFallback: true,
30+
historyApiFallback: {
31+
rewrites: [
32+
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
33+
],
34+
},
3035
hot: true,
36+
contentBase: false, // since we use CopyWebpackPlugin.
3137
compress: true,
3238
host: HOST || config.dev.host,
3339
port: PORT || config.dev.port,
@@ -57,6 +63,14 @@ const devWebpackConfig = merge(baseWebpackConfig, {
5763
favicon: resolve('favicon.ico'),
5864
title: 'vue-element-admin'
5965
}),
66+
// copy custom static assets
67+
new CopyWebpackPlugin([
68+
{
69+
from: path.resolve(__dirname, '../static'),
70+
to: config.dev.assetsSubDirectory,
71+
ignore: ['.*']
72+
}
73+
])
6074
]
6175
})
6276

build/webpack.prod.conf.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ const webpackConfig = merge(baseWebpackConfig, {
127127
var context = module.context;
128128
return context && (context.indexOf('xlsx') >= 0);
129129
}
130+
}),
131+
// split tinymce into its own file
132+
new webpack.optimize.CommonsChunkPlugin({
133+
async: 'tinymce',
134+
minChunks(module) {
135+
var context = module.context;
136+
return context && (context.indexOf('tinymce') >= 0);
137+
}
130138
}),
131139
// split codemirror into its own file
132140
new webpack.optimize.CommonsChunkPlugin({

src/components/Tinymce/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// Import Tinymce
1212
import tinymce from 'tinymce/tinymce'
1313
14+
tinymce.baseURL = 'static/tinymce'
15+
1416
// A theme is also required
1517
import 'tinymce/themes/modern/theme'
1618

0 commit comments

Comments
 (0)