提交 0e278acb 编写于 作者: fxy060608's avatar fxy060608

fix(cli): dynamic entry(nvue)

上级 c0ca4bf8
......@@ -12,6 +12,7 @@ const {
const WebpackAppPlusNVuePlugin = require('../packages/webpack-app-plus-nvue-plugin')
const WebpackErrorsPlugin = require('@dcloudio/vue-cli-plugin-uni/packages/webpack-errors-plugin')
const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new')
const onErrors = require('@dcloudio/vue-cli-plugin-uni/util/on-errors')
......@@ -91,9 +92,9 @@ const rules = [{
}
},
jsPreprocessorLoader
],
exclude (modulePath) {
return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1
],
exclude (modulePath) {
return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1
}
},
{
......@@ -146,6 +147,7 @@ if (process.env.UNI_USING_NVUE_COMPILER) {
})
}
if (process.env.UNI_USING_NATIVE) {
plugins.push(new WebpackUniMPPlugin())
plugins.push(new CopyWebpackPlugin([{
from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
to: 'static'
......@@ -170,13 +172,15 @@ if (process.env.UNI_USING_NATIVE) {
}]))
}
module.exports = function (entry) {
module.exports = function () {
return {
target: 'node', // 激活 vue-loader 的 isServer 逻辑
mode: process.env.NODE_ENV,
devtool: process.env.NODE_ENV === 'development' ? 'inline-source-map' : false,
watch: process.env.NODE_ENV === 'development',
entry,
entry () {
return process.UNI_NVUE_ENTRY
},
externals: {
'vue': 'Vue'
},
......
......@@ -67,25 +67,26 @@ function addSubPackagesRequire (compilation) {
class WebpackUniMPPlugin {
apply (compiler) {
compiler.hooks.emit.tapPromise('webpack-uni-mp-emit', compilation => {
return new Promise((resolve, reject) => {
addSubPackagesRequire(compilation)
if (!process.env.UNI_USING_NATIVE) {
compiler.hooks.emit.tapPromise('webpack-uni-mp-emit', compilation => {
return new Promise((resolve, reject) => {
addSubPackagesRequire(compilation)
generateJson(compilation)
generateJson(compilation)
// app.js,app.wxss
generateApp(compilation)
.forEach(({
file,
source
}) => emitFile(file, source, compilation))
// app.js,app.wxss
generateApp(compilation)
.forEach(({
file,
source
}) => emitFile(file, source, compilation))
generateComponent(compilation)
generateComponent(compilation)
resolve()
resolve()
})
})
})
}
compiler.hooks.invalid.tap('webpack-uni-mp-invalid', (fileName, changeTime) => {
if (
fileName &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册