Skip to content

Instantly share code, notes, and snippets.

@jawnsy
Created November 3, 2017 16:10
Show Gist options
  • Save jawnsy/cfd4d5c51c04dcf2ac3895bfabcf3cf5 to your computer and use it in GitHub Desktop.
Save jawnsy/cfd4d5c51c04dcf2ac3895bfabcf3cf5 to your computer and use it in GitHub Desktop.
Webpack config for Vue + TypeScript
const util = require('./util');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
main: util.resolve('src', 'main.ts'),
},
output: {
filename: '[name].bundle.js',
path: util.resolve('dist'),
},
module: {
rules: [{
test: /\.(ts|tsx)$/,
enforce: 'pre',
use: [{
loader: 'tslint-loader',
options: {
typeCheck: true,
},
}],
exclude: /node_modules/,
}, {
test: /\.vue$/,
use: [
'vue-loader',
],
}, {
test: /\.(ts|tsx)$/,
use: [{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [
/\.vue$/,
],
},
}],
exclude: /node_modules/,
}, {
test: /\.(sass|scss)$/,
use: [
'style-loader',
'css-loader',
'sass-loader',
],
}, {
test: /\.(png|jpg|jpeg|gif|svg|webp)$/,
loader: 'url-loader',
options: {
limit: 16384,
name: 'static/img/[name].[hash:7].[ext]',
},
}, {
test: /\.(mp3|mp4|webm|ogg|wav|flac|aac)$/,
loader: 'url-loader',
options: {
limit: 16384,
name: 'static/media/[name].[hash:7].[ext]',
},
}, {
test: /\.(woff|woff2|eot|ttf|otf)$/,
loader: 'url-loader',
options: {
limit: 16384,
name: 'static/fonts/[name].[hash:7].[ext]',
},
}],
},
plugins: [
new HtmlWebpackPlugin({
template: util.resolve('src', 'index.html'),
}),
],
resolve: {
extensions: [ '.ts', '.js', '.vue', '.json' ],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment