切ts ing,js文件转ts后缀
This commit is contained in:
1279
package-lock.json
generated
Normal file
1279
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -27,6 +27,8 @@
|
||||
"webpack": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-loader": "^5.3.1",
|
||||
"typescript": "^3.2.2",
|
||||
"webpack-cli": "^2.1.3"
|
||||
}
|
||||
}
|
||||
|
||||
17
renameJsFile.js
Normal file
17
renameJsFile.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
dir = './src/util',
|
||||
match = RegExp('.js', 'g'),
|
||||
replace = '.ts',
|
||||
files;
|
||||
|
||||
files = fs.readdirSync(dir);
|
||||
|
||||
files.filter(function(file) {
|
||||
return file.match(match);
|
||||
}).forEach(function(file) {
|
||||
var filePath = path.join(dir, file),
|
||||
newFilePath = path.join(dir, file.replace(match, replace));
|
||||
console.log({filePath, newFilePath})
|
||||
fs.renameSync(filePath, newFilePath);
|
||||
});
|
||||
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "./build/",
|
||||
"noImplicitAny": true,
|
||||
"module": "es6",
|
||||
"target": "es5",
|
||||
"allowJs": true
|
||||
}
|
||||
}
|
||||
5
typings/wx.d.ts
vendored
Normal file
5
typings/wx.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// 临时解决微信ts
|
||||
declare var wx: any;
|
||||
declare function Component(...args: any[]): any;
|
||||
declare function requirePlugin(pluginName: string): any;
|
||||
type TODO = any;
|
||||
@@ -1,34 +1,61 @@
|
||||
let path = require('path');
|
||||
let webpack = require('webpack');
|
||||
let pk = require('./package.json');
|
||||
let path = require("path");
|
||||
let webpack = require("webpack");
|
||||
let pk = require("./package.json");
|
||||
|
||||
module.exports = [{
|
||||
mode: 'production',
|
||||
entry: './src/index.js',
|
||||
module.exports = [
|
||||
{
|
||||
mode: "production",
|
||||
entry: "./src/index.ts",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: "ts-loader",
|
||||
exclude: /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".tsx", ".ts", ".js"]
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, 'build'),
|
||||
filename: 'weRequest.min.js',
|
||||
library: "weRequest",
|
||||
libraryTarget: "commonjs-module"
|
||||
path: path.join(__dirname, "build"),
|
||||
filename: "weRequest.min.js",
|
||||
library: "weRequest",
|
||||
libraryTarget: "commonjs-module"
|
||||
},
|
||||
plugins: [
|
||||
new webpack.BannerPlugin({
|
||||
banner: `weRequest ${pk.version}\n${pk.homepage}`
|
||||
})
|
||||
new webpack.BannerPlugin({
|
||||
banner: `weRequest ${pk.version}\n${pk.homepage}`
|
||||
})
|
||||
]
|
||||
}, {
|
||||
mode: 'development',
|
||||
entry: './src/index.js',
|
||||
output: {
|
||||
path: path.join(__dirname, 'build'),
|
||||
filename: 'weRequest.js',
|
||||
library: "weRequest",
|
||||
libraryTarget: "commonjs-module"
|
||||
},
|
||||
{
|
||||
mode: "development",
|
||||
entry: "./src/index.ts",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: "ts-loader",
|
||||
exclude: /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
devtool: 'inline-source-map',
|
||||
resolve: {
|
||||
extensions: [".tsx", ".ts", ".js"]
|
||||
},
|
||||
output: {
|
||||
path: path.join(__dirname, "build"),
|
||||
filename: "weRequest.js",
|
||||
library: "weRequest",
|
||||
libraryTarget: "commonjs-module"
|
||||
},
|
||||
devtool: "inline-source-map",
|
||||
plugins: [
|
||||
new webpack.BannerPlugin({
|
||||
banner: `weRequest ${pk.version}\n${pk.homepage}`
|
||||
})
|
||||
new webpack.BannerPlugin({
|
||||
banner: `weRequest ${pk.version}\n${pk.homepage}`
|
||||
})
|
||||
]
|
||||
}]
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user