Open
Description
As the title explains, it would be nice to have a vue: true
option instead of having to manually configure it.
I've got a manual setup working for Vue + TS (with class component and .vue files support) and the following was needed:
NPM:
npm i -D vue vue-template-compiler vue-loader vue-class-component ts-loader babel-preset-typescript-vue @babel/plugin-proposal-decorators @babel/plugin-proposal-class-properties
wpackio.project.js:
const { VueLoaderPlugin } = require("vue-loader");
module.exports = {
files: [
{
name: "xyz",
entry: {},
webpackConfig: {
module: {
rules: [
{
test: /\.vue$/,
loader: "vue-loader",
options: {
esModule: true,
},
},
{
test: /\.ts$/,
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/],
},
},
],
},
plugins: [new VueLoaderPlugin()],
},
},
....
tsBabelOverride: (defaults) => ({
...defaults,
presets: ["babel-preset-typescript-vue"],
plugins: [
["@babel/proposal-decorators", { legacy: true }],
["@babel/proposal-class-properties", { loose: true }],
],
}),
...
alias: {
vue$: "vue/dist/vue.esm.js",
},
Add a vue-shim.d.ts
to your typings folder:
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}
Make sure your typings are loaded in your tsconfig.json, something like:
"typeRoots": ["node_modules/@types", "typings"]
For a working example using a child theme see: https://github.com/michaelw85/wp-bedrock-wpack-vuejs
Metadata
Metadata
Assignees
Labels
No labels