Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions build/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const { VueLoaderPlugin } = require('vue-loader');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const fs = require('fs');
const SvgSpritePlugin = require('../tool/plugin-svg-sprite');

const distPath = path.resolve(__dirname, '../public');

const svgPath = path.resolve(__dirname, '../src/asset/icon');

module.exports = (env, argv) => {

const isDev = argv.mode === 'development';

let configLocal = {};
if (isDev) {
const configLocalPath = path.resolve(__dirname, '../config/config.local.js');
const configLocalPath = path.resolve(
__dirname,
'../config/config.local.js'
);
if (fs.existsSync(configLocalPath)) {
configLocal = require(configLocalPath);
}
}

return [{
return [
{
entry: path.resolve(__dirname, '../src/main.js'),
output: {
publicPath: './',
Expand Down Expand Up @@ -77,7 +81,11 @@ module.exports = (env, argv) => {
]
},
{
test: /\.(svg|html)$/,
test: /\.svg$/,
type: 'asset/source'
},
{
test: /\.html$/,
use: [
{
loader: 'html-loader',
Expand Down Expand Up @@ -114,9 +122,16 @@ module.exports = (env, argv) => {
vue: 'Vue'
},
plugins: [
new SvgSpritePlugin({
spriteFilename: '../asset/sprite.svg',
svgPath: svgPath
}),
new webpack.DefinePlugin({
// It can be used in the code directly.
CONFIG_LOCAL: JSON.stringify(configLocal),
CONFIG_LOCAL: JSON.stringify(configLocal)
}),
new webpack.DefinePlugin({
__VUE_PROD_DEVTOOLS__: JSON.stringify(!isDev)
}),
new webpack.IgnorePlugin({
resourceRegExp: /^fs$/
Expand Down
Loading