Created
May 1, 2020 06:59
-
-
Save ushironoko/b6991b5427f4dba5860969ba3e67b614 to your computer and use it in GitHub Desktop.
vue3 webpack conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable @typescript-eslint/no-var-requires */ | |
const { resolve } = require('path') | |
const HtmlWebpackPlugin = require('html-webpack-plugin') | |
const { CleanWebpackPlugin } = require('clean-webpack-plugin') | |
const { VueLoaderPlugin } = require('vue-loader') | |
const webpack = require('webpack') | |
const outputPath = resolve(__dirname, 'dist') | |
/** @type {import('webpack').ConfigurationFactory} */ | |
const config = (env = {}) => ({ | |
mode: env.prod ? 'production' : 'development', | |
devtool: env.prod ? 'source-map' : 'inline-source-map', | |
devServer: { | |
contentBase: outputPath, | |
historyApiFallback: true, | |
hot: true, | |
stats: 'minimal', | |
}, | |
output: { | |
path: outputPath, | |
publicPath: '/', | |
filename: 'bundle.js', | |
}, | |
entry: [resolve(__dirname, 'src/main.ts')], | |
module: { | |
rules: [ | |
{ | |
test: /\.ts$/, | |
exclude: /node_modules|vue\/src/, | |
use: [ | |
{ | |
loader: 'ts-loader', | |
options: { | |
appendTsSuffixTo: [/\.vue$/], | |
transpileOnly: true, | |
}, | |
}, | |
], | |
}, | |
{ | |
test: /\.vue$/, | |
use: 'vue-loader', | |
}, | |
], | |
}, | |
resolve: { | |
alias: { | |
vue: '@vue/runtime-dom', | |
'~': resolve('src'), | |
}, | |
extensions: ['.ts', 'd.ts', '.tsx', '.js', '.vue'], | |
}, | |
plugins: [ | |
new VueLoaderPlugin(), | |
new HtmlWebpackPlugin({ | |
template: resolve(__dirname, 'src/index.html'), | |
}), | |
new CleanWebpackPlugin(), | |
], | |
}) | |
module.exports = config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment