Vue-cli 版本 3 BETA webpack 配置 [英] Vue-cli version 3 BETA webpack configuration
问题描述
我正在尝试学习和测试即将发布的 vuejs/vue-cli (beta 3.0) 版本,这将是朝着最简单的 webpack 配置迈出的一大步.同时,有几个例子......
I am trying to learn and test the upcoming version of vuejs/vue-cli ( beta 3.0 ) which will be a big step toward an easiest webpack configuration. In the meantime, there is few examples....
作为测试,我尝试从 vue-cli v2 开始
As a test I tried to go from the vue-cli v2
webpack.dev.conf.js
plugins: [
...
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
到新的 vue-cli 版本 3(测试版)
to the new vue-cli version 3 ( beta)
vue.config.js
const path = require('path')
module.exports = {
chainWebpack: config => {
config
.plugin('copy')
.use(require('copy-webpack-plugin')), [{
from: path.resolve(__dirname, '../static'),
to: 'static', ignore: ['.*']
}]
}
}
运行
npm run serve
不抱怨...
所以它似乎没问题,但我想知道是否有一些关于此主题的论文、tuts、示例...目前我只通过阅读现有代码源来发现新功能
so it seems to be OK, but I would like to know if there are some papers , tuts , examples already existing on this topic... fr the time being I only discover new features by reading existing code source
目前我正在努力转换这个:
Currently I am struggling in converting this :
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}),
我试过了.
config
.plugin('provide')
.use(require('webpack.ProvidePlugin')), [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}]
但我收到一个错误:
INFO Starting development server...
ERROR Error: Cannot find module 'webpack.ProvidePlugin'
Error: Cannot find module 'webpack.ProvidePlugin'
at Function.Module._resolveFilename (module.js:536:15)
推荐答案
你的 require 命令错误/不必要,与 webpack 或 vue-cli 无关
Your require command is wrong/unecessary, nothing to do with webpack or vue-cli
示例代码:
config
.plugin('provide')
.use(require('webpack').ProvidePlugin, [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}])
这篇关于Vue-cli 版本 3 BETA webpack 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!