Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const qs = require('querystring')
const {
md5,
removeExt,
getPlatformExts
} = require('@dcloudio/uni-cli-shared')
const {
cacheTemplate,
cacheCompilerOptions,
getPlatformTarget
} = require('./shared')
const templateExt = getPlatformExts().template
module.exports = function (content) {
if (process.env.UNI_USING_COMPONENTS) {
return require('./template-new').call(this, content)
}
this.cacheable && this.cacheable()
const realResourcePath = path.relative(process.env.UNI_INPUT_DIR, this.resourcePath)
if (process.env.UNI_USING_COMPONENTS) {
// 向 uni-template-compier 传递 emitFile
const vueLoaderOptions = this.loaders[0]
if (vueLoaderOptions.ident === 'vue-loader-options') {
Object.assign(vueLoaderOptions.options.compilerOptions, {
resourcePath: removeExt(realResourcePath) + templateExt,
emitFile: this.emitFile
})
updateSpecialMethods,
getGlobalUsingComponents,
updateGenericComponents, // resolve
updateComponentGenerics, // define
updateUsingGlobalComponents
} = require('@dcloudio/uni-cli-shared/lib/cache')
const {
getPlatformFilterTag
} = require('@dcloudio/uni-cli-shared/lib/platform')
const {
normalizeNodeModules
} = require('./shared')
const templateExt = getPlatformExts().template
const filterTagName = getPlatformFilterTag() || ''
module.exports = function (content) {
this.cacheable && this.cacheable()
const vueLoaderOptions = this.loaders[0]
if (vueLoaderOptions.ident === 'vue-loader-options') {
const globalUsingComponents = getGlobalUsingComponents()
const realResourcePath = path.relative(process.env.UNI_INPUT_DIR, this.resourcePath)
const resourcePath = normalizeNodeModules(removeExt(realResourcePath) + templateExt)
const wxComponents = getWXComponents(resourcePath.replace(path.extname(resourcePath), ''))
const params = loaderUtils.parseQuery(this.resourceQuery)
/* eslint-disable no-mixed-operators */
const filterModules = JSON.parse(params && params['filter-modules'] || '{}')
Object.assign(vueLoaderOptions.options.compilerOptions, {
cacheIdentifier: false
}))
.end()
.use('uniapp-custom-block-loader')
.loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader'))
.options({
compiler: getPlatformCompiler()
})
.end()
.use('uniapp-nvue-loader')
.loader(require.resolve('@dcloudio/webpack-uni-mp-loader/lib/style.js'))
.end()
.uses
.delete('cache-loader')
const styleExt = getPlatformExts().style
webpackConfig.plugin('extract-css')
.init((Plugin, args) => new Plugin({
filename: '[name]' + styleExt
}))
if (
process.env.NODE_ENV === 'production' &&
process.env.UNI_PLATFORM !== 'app-plus'
) {
const OptimizeCssnanoPlugin = require('../packages/@intervolga/optimize-cssnano-plugin/index.js')
webpackConfig.plugin('optimize-css')
.init((Plugin, args) => new OptimizeCssnanoPlugin({
sourceMap: false,
filter (assetName) {
return path.extname(assetName) === styleExt