2020-08-13 15:18:26 +08:00
|
|
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
|
|
const path = require('path')
|
|
|
|
const { VueLoaderPlugin } = require('vue-loader')
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
2020-08-14 01:37:25 +08:00
|
|
|
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
const isProd = process.env.NODE_ENV === 'production'
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: isProd ? 'production' : 'development',
|
|
|
|
devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map',
|
|
|
|
entry: path.resolve(__dirname, './entry.js'),
|
|
|
|
output: {
|
|
|
|
path: path.resolve(__dirname, '../website-dist'),
|
|
|
|
publicPath: '/',
|
|
|
|
},
|
|
|
|
stats: 'verbose',
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
use: 'vue-loader',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(sass|scss|css)$/,
|
|
|
|
use: [
|
|
|
|
'style-loader',
|
|
|
|
'css-loader',
|
2020-08-13 17:31:58 +08:00
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
implementation: require('sass'),
|
|
|
|
},
|
|
|
|
},
|
2020-08-13 15:18:26 +08:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
appendTsSuffixTo: [/\.vue$/],
|
|
|
|
transpileOnly: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.md$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'vue-loader',
|
|
|
|
options: {
|
|
|
|
compilerOptions: {
|
|
|
|
preserveWhitespace: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: path.resolve(__dirname, './md-loader/index.js'),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
|
|
|
|
loader: 'url-loader',
|
|
|
|
// todo: 这种写法有待调整
|
|
|
|
query: {
|
|
|
|
limit: 10000,
|
|
|
|
name: path.posix.join('static', '[name].[hash:7].[ext]'),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.ts', '.js', '.vue', '.json'],
|
|
|
|
alias: {
|
|
|
|
'vue': '@vue/runtime-dom',
|
|
|
|
examples: path.resolve(__dirname),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new VueLoaderPlugin(),
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
template: './website/index.tpl',
|
|
|
|
filename: './index.html',
|
|
|
|
favicon: './website/favicon.ico',
|
|
|
|
}),
|
2020-08-14 01:37:25 +08:00
|
|
|
// new BundleAnalyzerPlugin(),
|
2020-08-13 15:18:26 +08:00
|
|
|
],
|
|
|
|
devServer: {
|
|
|
|
inline: true,
|
|
|
|
hot: true,
|
|
|
|
stats: 'minimal',
|
|
|
|
publicPath: '/',
|
|
|
|
contentBase: __dirname,
|
|
|
|
overlay: true,
|
|
|
|
},
|
|
|
|
}
|