Используйте DllPlugin и DllReferencePlugin Wrong, когда vue/cli3.0
Я хотел вытащить пакеты зависимостей, но у меня была проблема. с vue/cli3.0
онлайн ссылка https://github.com/Sayid1/dll-test
основной код
vue.config.js
var bundleConfig = require('./bundle-config.json')
module.exports = {
configureWebpack: {
plugins: [
new webpack.DllReferencePlugin({
manifest: require('./dll/manifest.json')
}),
new HtmlWebpackPlugin({
inject: true,
template: './public/index.html',
filename: 'index.html',
vendorJsName: bundleConfig.vender.js,
})
]
}
}
webpack.config.dll.js
const AssetsPlugin = require('assets-webpack-plugin')
module.exports = {
entry: {
vender: ['vue/dist/vue.runtime.common.js']
},
output: {
path: path.join(__dirname, 'dll'),
filename: 'dll.[name]_[hash].js',
library: '[name]_[hash]'
},
plugins: [
new webpack.DllPlugin({
name: '[name]_[hash]',
path: path.join(__dirname, 'dll', 'manifest.json')
}),
new AssetsPlugin({
filename: 'bundle-config.json',
path: './'
})
]
}
я запускаю этот скрипт:
webpack -p --progress --config webpack.config.dll.js
затем запустить сервер
произошла ошибка.
Uncaught SyntaxError: Unexpected token <
Uncaught ReferenceError: vender_87f3be8acd6aadd91537 is not defined
at eval (eval at dll-reference vender_87f3be8acd6aadd91537 (app.js:2106), <anonymous>:1:18)
at Object.dll-reference vender_87f3be8acd6aadd91537 (app.js:2106)
at __webpack_require__ (app.js:724)
at fn (app.js:101)
at eval (global.js from dll-reference vender_87f3be8acd6aadd91537?478a:1)
at Object../node_modules/webpack/buildin/global.js (app.js:1896)
at __webpack_require__ (app.js:724)
at fn (app.js:101)
at eval (punycode.js:521)
at Object../node_modules/node-libs-browser/node_modules/punycode/punycode.js (app.js:1685)