Skip to content

Instantly share code, notes, and snippets.

@webfacer
Last active August 12, 2021 05:09
Show Gist options
  • Save webfacer/56c5099eda0d2b67fcdfc22dc5a20927 to your computer and use it in GitHub Desktop.
Save webfacer/56c5099eda0d2b67fcdfc22dc5a20927 to your computer and use it in GitHub Desktop.
Vue + Typescript + MochaPack Testing
{
"name": "clubwien-template-vue",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"eslint": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
"test": "mochapack --mode development --webpack-config webpack.config.development.js --require test/setup.js test/**/*.spec.js",
"build:prod": "vue-cli-service build --modern --mode production"
},
"dependencies": {
"axios": "^0.19.2",
"core-js": "^2.6.11",
"moment": "^2.24.0",
"npm": "^6.13.7",
"vue": "^2.6.11",
"vue-agile": "^1.0.11",
"vue-class-component": "^7.2.2",
"vue-jsonp": "^0.1.8",
"vue-property-decorator": "^8.3.0",
"vue-select": "^3.4.0",
"vue-types": "^1.7.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.12.1",
"@vue/cli-plugin-eslint": "^4.1.2",
"@vue/cli-plugin-typescript": "^3.12.1",
"@vue/cli-service": "^3.12.1",
"@vue/eslint-config-prettier": "^5.0.0",
"@vue/eslint-config-typescript": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.31",
"axios-mock-adapter": "^1.17.0",
"babel-loader": "^8.0.6",
"babel-plugin-istanbul": "^6.0.0",
"eslint": "^5.16.0",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^5.0.0",
"expect": "^25.1.0",
"flush-promises": "^1.0.2",
"jsdom": "^16.1.0",
"jsdom-global": "^3.0.2",
"mocha": "^6.2.2",
"mochapack": "^1.1.13",
"node-sass": "^4.13.1",
"nyc": "^15.0.0",
"path": "^0.12.7",
"prettier": "^1.19.1",
"sass-loader": "^7.3.1",
"ts-loader": "^6.2.1",
"typescript": "^3.7.5",
"vue-loader": "latest",
"vue-template-compiler": "^2.6.11",
"webpack": "^4.41.5",
"webpack-dev-server": "^3.10.2",
"webpack-node-externals": "^1.7.2"
},
"nyc": {
"include": [
"src/**/*.(js|vue)"
],
"instrument": false,
"sourceMap": false
}
}
const path = require("path");
const webpack = require("webpack");
const { VueLoaderPlugin } = require("vue-loader");
const nodeExternals = require("webpack-node-externals");
module.exports = {
plugins: [new VueLoaderPlugin()],
entry: "./src/main.ts",
output: {
path: path.resolve(__dirname, "./dist"),
publicPath: "/dist/",
filename: "build.js"
//devtoolModuleFilenameTemplate: "[absolute-resource-path]",
//devtoolFallbackModuleFilenameTemplate: "[absolute-resource-path]?[hash]"
},
resolve: {
alias: {
vue$: "vue/dist/vue.esm.js",
"@": path.resolve(__dirname, "src")
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: "vue-loader"
},
{
test: /\.scss$/,
use: ["vue-style-loader", "css-loader", "sass-loader"]
},
{
test: /\.(js|ts|tsx)$/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true
}
}
},
{
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: "file-loader",
options: {
name: "[name].[ext]?[hash]"
}
}
]
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: "#eval-source-map"
};
if (process.env.NODE_ENV === "production") {
module.exports.devtool = "#source-map";
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
]);
}
// test specific setups
if (process.env.NODE_ENV === "test") {
module.exports.externals = [nodeExternals()];
module.exports.devtool = "eval";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment