first version
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
const path = require('path');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const LessPluginAutoPrefix = require('less-plugin-autoprefix');
|
||||
const Dotenv = require('dotenv-webpack');
|
||||
|
||||
module.exports = {
|
||||
entry: {
|
||||
app: path.resolve(__dirname, '../src/main.tsx'),
|
||||
},
|
||||
output: {
|
||||
filename: 'js/[name].[chunkhash:8].js',
|
||||
path: path.resolve(__dirname, '../dist/fiora'),
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
||||
alias: {
|
||||
'@fiora': path.resolve(__dirname, '../src/@fiora/'),
|
||||
},
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
loader: 'babel-loader',
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
plugins: [
|
||||
...(process.env.NODE_ENV === 'development'
|
||||
? [require.resolve('react-refresh/babel')]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'linaria/loader',
|
||||
options: {
|
||||
sourceMap: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
exclude: /node_modules/,
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
use: [
|
||||
'style-loader',
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
importLoaders: 2,
|
||||
modules: {
|
||||
localIdentName: '[local]--[hash:base64:5]',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
loader: 'less-loader',
|
||||
options: {
|
||||
lessOptions: {
|
||||
plugins: [
|
||||
new LessPluginAutoPrefix({
|
||||
enable: true,
|
||||
options: {
|
||||
browsers: ['last 3 versions'],
|
||||
},
|
||||
}),
|
||||
],
|
||||
},
|
||||
sourceMap: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.css$/i,
|
||||
use: ['style-loader', 'css-loader'],
|
||||
},
|
||||
{
|
||||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
limit: 4096,
|
||||
name: 'images/[name].[ext]',
|
||||
esModule: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
limit: 4096,
|
||||
name: 'fonts/[name].[hash:8].[ext]',
|
||||
esModule: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.(mp3)(\?.*)?$/,
|
||||
loader: 'url-loader',
|
||||
options: {
|
||||
limit: 4096,
|
||||
name: 'audios/[name].[hash:8].[ext]',
|
||||
esModule: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
filename: 'index.html',
|
||||
template: path.resolve(__dirname, '../src/template.html'),
|
||||
inject: true,
|
||||
}),
|
||||
new CleanWebpackPlugin(),
|
||||
new Dotenv({
|
||||
silent: true,
|
||||
}),
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
const path = require('path');
|
||||
const { merge } = require('webpack-merge');
|
||||
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
||||
const common = require('./webpack.common.js');
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: 'development',
|
||||
output: {
|
||||
publicPath: '/',
|
||||
},
|
||||
devtool: 'inline-source-map',
|
||||
devServer: {
|
||||
hot: true,
|
||||
contentBase: ['./dist'],
|
||||
historyApiFallback: {
|
||||
rewrites: [{ from: /\/invite\/group\/[\w\d]+/, to: '/index.html' }],
|
||||
},
|
||||
proxy: {
|
||||
'/avatar': 'http://localhost:9200',
|
||||
'/GroupAvatar': 'http://localhost:9200',
|
||||
'/Avatar': {
|
||||
target: 'http://localhost:9200',
|
||||
pathRewrite: { '^/Avatar': '/avatar' },
|
||||
},
|
||||
'/favicon-*.png': 'http://localhost:9200',
|
||||
},
|
||||
},
|
||||
plugins: [new ReactRefreshWebpackPlugin()],
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
const { merge } = require('webpack-merge');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const ScriptExtHtmlPlugin = require('script-ext-html-webpack-plugin');
|
||||
const WorkboxPlugin = require('workbox-webpack-plugin');
|
||||
const WebpackBar = require('webpackbar');
|
||||
const common = require('./webpack.common.js');
|
||||
|
||||
module.exports = merge(common, {
|
||||
mode: 'production',
|
||||
output: {
|
||||
publicPath: process.env.PublicPath || '/',
|
||||
},
|
||||
devtool: false,
|
||||
optimization: {
|
||||
minimize: true,
|
||||
minimizer: [
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
format: {
|
||||
comments: false,
|
||||
},
|
||||
},
|
||||
extractComments: false,
|
||||
}),
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
new ScriptExtHtmlPlugin({
|
||||
custom: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
attribute: 'crossorigin',
|
||||
value: 'anonymous',
|
||||
},
|
||||
],
|
||||
}),
|
||||
new WorkboxPlugin.GenerateSW({
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
}),
|
||||
new WebpackBar(),
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user