UPDATE:vue-表-2现在已经被预编译,所以不需要加载器。对于templates选项,建议使用范围槽,这也不需要任何特殊设置
我正在使用gulp、webpack和babel-加载程序来构建一些文件(vue-tables 2):
gulp.task('scripts-vue-tables', function() {
gulp.src('node_modules/vue-tables-2/index.js')
.pipe(webpackstream({
output: {
path: __dirname,
filename: "vue-tables-2.js",
library: 'VueTables2',
libraryTarget: 'var'
}
}
))
.pipe(gulp.dest('public/vendor/vue-tables-2/js/'));
}在webpack.config.js中,我包括:
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
query: {
presets: ["latest", "react", "stage-0"],
plugins: ["transform-vue-jsx"]
}
},
]并在.babelrc中包含了相同的
{
"presets": ["latest", "react", "stage-0"],
"plugins": ["transform-vue-jsx"]
}但是,运行scripts-vue-tables任务会产生错误:
Module parse failed: \node_modules\vue-tables-2\lib\template.jsx Unexpected token (15:7)
You may need an appropriate loader to handle this file type.注意:总的来说,我尝试遵循概述的这里步骤。
发布于 2016-11-11 07:54:59
webpack.config.js是读取的文件,如果您使用webpack CLI接口,但是在您的Gulp示例中使用它,它将不会被使用。你可能会想要像
.pipe(webpackstream(Object.assign({
output: {
path: __dirname,
filename: "vue-tables-2.js",
library: 'VueTables2',
libraryTarget: 'var'
},
}, require('./webpack.config')))加载Webpack配置和特殊的output逻辑。
https://stackoverflow.com/questions/40538774
复制相似问题