node框架下,主流用gulp,想用webpack处理vue文件,但是始终抱错
gulp.task('vue',function () {
const config = {
output: {
filename: "[name].bundle.js"
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('views'),
'components': resolve('views/components')
},
},
module: {
rules: [
{
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('views'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter')
}
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('views')]
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
css: ExtractTextPlugin.extract({
use: 'css-loader',
fallback: 'vue-style-loader'
})
}
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'img/[name]_[hash:7].[ext]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: 'font/[name]_[hash:7].[ext]'
}
}
]
},
devtool: 'source-map',
plugins: [
// 自动注入引入文件
new HtmlWebpackPlugin({
filename: 'ui.html',
template: 'views/ui.html',
inject: true
})
]
};
if (!dev) {
//生产环境不声称sourcemap
delete config.devtool;
}
let result = gulp.src('views/scripts/es6/ui.js')
.pipe(named())
.pipe(webpackStream(config),webpack);
return result
.pipe(gulp.dest('public/js/'));
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文件不存在,是你那个gulp.src('views/scripts/es6/ui.js')这个路径不对