Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
globalObject: process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'global',
sourceMapFilename: '../.sourcemap/' + process.env.UNI_PLATFORM + '/[name].js.map'
},
performance: {
hints: false
},
resolve: {
extensions: ['.nvue'],
alias: { // 仅 mp-weixin
'mpvue-page-factory': require.resolve(
'@dcloudio/vue-cli-plugin-uni/packages/mpvue-page-factory')
}
},
module: {
rules: [{
test: path.resolve(process.env.UNI_INPUT_DIR, getMainEntry()),
use: [{
loader: '@dcloudio/webpack-uni-mp-loader/lib/main'
}]
}, {
resourceQuery: /vue&type=script/,
use: [{
loader: '@dcloudio/webpack-uni-mp-loader/lib/script'
}]
}, {
resourceQuery: /vue&type=template/,
use: [{
loader: '@dcloudio/webpack-uni-mp-loader/lib/template'
}]
}, {
resourceQuery: [
/lang=wxs/,
plugins.push(new WebpackHtmlAppendPlugin(
`
`
))
}
const vueConfig = {
parallel: false, // 因为传入了自定义 compiler,避免参数丢失,禁用parallel
publicPath,
pages: {
index: {
// page 的入口
entry: path.resolve(process.env.UNI_INPUT_DIR, getMainEntry()),
// 模板来源
template,
// 在 dist/index.html 的输出
filename: 'index.html',
// 当使用 title 选项时,
// template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title>
title,
// 在这个页面中包含的块,默认情况下会包含
// 提取出来的通用 chunk 和 vendor chunk。
chunks: ['chunk-vendors', 'chunk-common', 'index'],
baseUrl: publicPath
}
}
}
if (devServer && Object.keys(devServer).length) {
`import 'uni-pages';import 'uni-${process.env.UNI_PLATFORM}';`
} else {
beforeCode = `import 'uni-pages';`
}
const rules = [{
test: path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
use: [{
loader: 'babel-loader'
}, {
loader: '@dcloudio/webpack-uni-pages-loader'
}],
type: 'javascript/auto'
},
{
test: path.resolve(process.env.UNI_INPUT_DIR, getMainEntry()),
// resourceQuery: /type=wrapper/,
use: [{
loader: 'wrap-loader',
options: {
before: [
beforeCode + statCode
]
}
}]
},
{
resourceQuery: /vue&type=template/,
use: [{
loader: resolve('packages/webpack-preprocess-loader'),
options: htmlPreprocessOptions
}]