Comments (5)
webpak
// webpack.config.js
module.exports = {
// ...
module: {
rules: [
// ...
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
// ...
{
loader: 'import-meta-loader',
}
]
}
]
}
}
vue cli
// vue.config.js
const importMetaLoader = require('import-meta-loader')
const path = require('path')
module.exports = {
// ...
chainWebpack: (config) => {
config.module.rule('ts')
.test(/\.ts$/)
.exclude.add(path.resolve('node_modules'))
.end()
.use(importMetaLoader)
.loader('import-meta-loader')
.options({
alias: Object.fromEntries(config.resolve.alias.store)
})
.end()
}
}
from vuecli-vite-template.
from vuecli-vite-template.
this project is vue cli ts demo,you can test
from vuecli-vite-template.
vue cli version: 5.0.8
// vue.config.js
const { defineConfig } = require('@vue/cli-service')
const importMetaLoader = require('import-meta-loader')
const path = require('path')
function setTSLoader (config, { use, loader, options }) {
const tsRule = config.module.rule('ts')
const tsLoader = tsRule.uses.store.get('ts-loader')
const tsOtherLoaders = new Map()
tsRule.uses.store.forEach((val, key) => {
if (key === 'ts-loader') return
tsOtherLoaders.set(key, val)
})
tsRule.uses.clear()
tsOtherLoaders.forEach((val, key) => {
tsRule.uses.store.set(key, val)
})
tsRule.test(/\.ts$/)
.exclude.add(path.resolve('node_modules'))
.end()
.use(use)
.loader(loader)
.options(options)
.end()
tsRule.uses.store.set('ts-loader', tsLoader)
}
module.exports = defineConfig({
transpileDependencies: true,
chainWebpack: (config) => {
setTSLoader(
config,
{
use: importMetaLoader,
loader: 'import-meta-loader',
options: Object.fromEntries(config.resolve.alias.store)
}
)
}
})
from vuecli-vite-template.
Can you take a look at the sample code of the vue cli ts version. self test is error. format path may have problem.
from vuecli-vite-template.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuecli-vite-template.