fix: adjust ts config to fix startup error

This commit is contained in:
Clark Du 2017-10-22 12:46:19 +08:00
parent c0a6ed9ea3
commit 05d0b7a3cd
2 changed files with 49 additions and 39 deletions

View File

@ -1,16 +1,26 @@
module.exports = function (options) {
module.exports = function(options) {
// Extend build
this.extendBuild((config) => {
this.extendBuild(config => {
const tsLoader = {
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/]
}
};
// Add TypeScript loader
config.module.rules.push({
test: /\.ts$/,
loader: 'ts-loader'
})
config.module.rules.push(
Object.assign(
{
test: /((client|server)\.js)|(\.tsx?)$/
},
tsLoader
)
);
// Add TypeScript loader for vue files
for (let rule of config.module.rules) {
if (rule.loader === 'vue-loader') {
rule.query.loaders.ts = 'ts-loader?{"appendTsSuffixTo":["\\\\.vue$"]}'
if (rule.loader === "vue-loader") {
rule.options.loaders.ts = tsLoader;
}
}
})
}
});
};

View File

@ -1,29 +1,29 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"experimentalDecorators": true,
"declaration": true,
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": true,
"removeComments": true,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"~": ["./"],
"~assets/*": ["./assets/*"],
"~components/*": ["./components/*"],
"~middleware/*": ["./middleware/*"],
"~pages/*": ["./pages/*"],
"~plugins/*": ["./plugins/*"],
"~static/*": ["./static/*"]
}
}
}
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"experimentalDecorators": true,
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": true,
"removeComments": true,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"allowJs": true,
"paths": {
"~/": ["./"],
"~/assets/*": ["./assets/*"],
"~/components/*": ["./components/*"],
"~/middleware/*": ["./middleware/*"],
"~/pages/*": ["./pages/*"],
"~/plugins/*": ["./plugins/*"],
"~/static/*": ["./static/*"]
}
}
}