From a9b51e7329b004aa2f0d921e9d3a7bc66fc913bd Mon Sep 17 00:00:00 2001 From: qiang Date: Sat, 10 Aug 2019 16:16:45 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E5=A2=9E=E5=8A=A0=20vue-config=20?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/collocation/vue-config.md | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/collocation/vue-config.md b/docs/collocation/vue-config.md index 3d4d19c8f..792948ce8 100644 --- a/docs/collocation/vue-config.md +++ b/docs/collocation/vue-config.md @@ -15,4 +15,44 @@ vue.config.js 是一个可选的配置文件,如果项目的根目录中存在 * runtimeCompiler 固定 false * productionSourceMap 固定 false * css.extract H5 平台固定 false,其他平台固定 true -* parallel 固定 false \ No newline at end of file +* parallel 固定 false + +**使用示例** + +**自定义静态资源目录** + +```js +const path = require('path') +const CopyWebpackPlugin = require('copy-webpack-plugin') + +module.exports = { + configureWebpack: { + plugins: [ + new CopyWebpackPlugin([ + { + from: path.join(__dirname, 'src/images'), + to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' : 'dev', process.env.UNI_PLATFORM, 'images') + } + ]) + ] + } +} +``` + +**注入全局依赖** + +```js +const webpack = require('webpack') + +module.exports = { + configureWebpack: { + plugins: [ + new webpack.ProvidePlugin({ + 'localStorage': ['mp-storage', 'localStorage'], + 'window.localStorage': ['mp-storage', 'localStorage'] + }) + ] + } +} +``` + -- GitLab