personal-website/front/webpack.config.cjs

80 lines
1.9 KiB
JavaScript
Raw Normal View History

2023-07-18 17:15:06 +00:00
// Generated using webpack-cli https://github.com/webpack/webpack-cli
const path = require('path');
const isProduction = process.env.NODE_ENV == 'production';
const stylesHandler = 'style-loader';
2023-07-19 01:06:13 +00:00
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const { experiments } = require('webpack');
2023-07-18 17:15:06 +00:00
const config = {
// entry: [ './src/wde-mobile.js'],
entry: {
2023-07-19 01:06:13 +00:00
desktop:[
'./src/wde/wde-desktop.js',
],
desktop_style: [
"./src/desktop.less",
],
finder : [
'./src/apps/finder/finder.js',
],
finder_style:[
'./src/apps/finder/finder.less',
]
2023-07-18 17:15:06 +00:00
},
output: {
// path: path.resolve(__dirname, 'dist'),
2023-07-19 01:06:13 +00:00
path: path.resolve('../res/dev-fs/dist'),
filename: '[name].js',
library: {
type: "module",
},
2023-07-18 17:15:06 +00:00
},
2023-07-19 01:06:13 +00:00
experiments: {
outputModule: true,
},
2023-07-18 17:15:06 +00:00
devServer: {
open: true,
host: 'localhost',
},
2023-07-18 20:47:12 +00:00
plugins: [new MiniCssExtractPlugin()],
2023-07-18 17:15:06 +00:00
module: {
rules: [
{
test: /\.(js|jsx)$/i,
loader: 'babel-loader',
},
{
test: /\.css$/i,
use: [stylesHandler,'css-loader'],
},
{
test: /\.less$/i,
2023-07-18 20:47:12 +00:00
// use: [stylesHandler, 'css-loader', 'less-loader'],
use: [MiniCssExtractPlugin.loader, 'css-loader', 'less-loader'],
2023-07-18 17:15:06 +00:00
},
{
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
type: 'asset',
},
// Add your rules for custom modules here
// Learn more about loaders from https://webpack.js.org/loaders/
],
},
};
module.exports = () => {
if (isProduction) {
config.mode = 'production';
} else {
config.mode = 'development';
}
return config;
};