Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
After recompiling copy-webpack-plugin does not update assets-manifest.json
import path from 'path';
import webpack from 'webpack';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import ManifestPlugin from 'webpack-manifest-plugin';
import WriteFilePlugin from 'write-file-webpack-plugin';
// import EntrypointsPlugin from '../webpackEntrypointPlugin';
import babelConfig from './babelLoaderConfig';
const cacheDir = path.resolve('node_modules/.cache');
const getThreadLoader = name => ({
loader: 'thread-loader',
options: {
name,
},
});
const config = {
cache: true,
target: 'web',
profile: true,
mode: 'development',
devtool: 'cheap-module-eval-source-map',
entry: {
main: ['./src/client/index.tsx'],
},
output: {
publicPath: '/',
filename: '[name].js',
chunkFilename: '[name].js',
path: path.resolve('./dist'),
hotUpdateChunkFilename: '[id].[hash].hot-update.js',
},
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx)$/,
include: path.resolve('./src'),
exclude: path.resolve('node_modules'),
use: [
{
loader: 'cache-loader',
options: {
cacheDirectory: path.resolve(cacheDir, 'client-js'),
},
},
getThreadLoader('client-js'),
{
loader: 'babel-loader',
options: babelConfig,
},
],
},
{
test: /\.svg$/,
include: [path.resolve('./src'), path.resolve('node_modules')],
use: [
{
loader: 'raw-loader',
options: {
name: '[name].[hash:8].[ext]',
},
},
],
},
{
test: /\.(ico)$/,
include: [path.resolve('./src'), path.resolve('node_modules')],
// exclude: path.resolve('node_modules'),
use: [
{
loader: 'file-loader',
options: {
name: '[name].[hash:8].[ext]',
},
},
],
},
{
test: /\.(mp3|m4r)$/,
include: [path.resolve('./src'), path.resolve('node_modules')],
// exclude: path.resolve('node_modules'),
use: [
{
loader: 'file-loader',
options: {
name: '[name].[hash:8].[ext]',
},
},
],
},
{
test: /\.(png|jpg|gif)$/,
include: [path.resolve('./src'), path.resolve('node_modules')],
// exclude: path.resolve('node_modules'),
use: [
{
loader: 'file-loader',
options: {
name: '[name].[hash:8].[ext]',
},
},
],
},
{
test: /\.css$/,
use: [
{
loader: 'cache-loader',
options: {
cacheDirectory: path.resolve(cacheDir, 'client-css'),
},
},
getThreadLoader('client-css'),
{
loader: 'style-loader/useable',
options: {
hmr: true,
},
},
{
loader: '@budarin/ts-css-loader',
options: {
EOL: 'LF',
modules: true,
browser: true,
server: true,
camelCase: true,
importLoaders: 1,
localIdentName: '[name].[local]_[hash:7]',
},
},
{
loader: 'postcss-loader',
},
],
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', 'jsx', '.json'],
modules: ['node_modules', 'src'],
},
plugins: [
// @ts-ignore
new CopyWebpackPlugin([
{ from: './.env.development' },
{ from: './src/common/assets/manifest.json' },
{ from: './src/common/assets/*.png', flatten: true },
{ from: './src/common/assets/favicon.ico' },
{ from: './src/common/assets/webPush/pushPackage.zip' },
{ from: './node_modules/react/umd/react.development.js' },
{ from: './node_modules/react-dom/umd/react-dom.development.js' },
]),
new ManifestPlugin({
fileName: 'assets-manifest.json',
}),
new webpack.HotModuleReplacementPlugin(),
// new EntrypointsPlugin({
// filename: 'entrypoints.json',
// space: 2,
// }),
new webpack.DefinePlugin({
__DEV__: true,
__PROD__: false,
__BROWSER__: true,
__SERVER__: false,
'process.env.__BROWSER__': true, // for components
'process.env.__SERVER__': false,
}),
new webpack.WatchIgnorePlugin([/css\.d\.ts$/]), // due to slow building ignore changes
new WriteFilePlugin(),
],
externals: {
react: 'React',
'react-dom': 'ReactDOM',
},
devServer: {
hot: true,
// lazy: true,
inline: true,
overlay: true,
compress: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
proxy: {
'/ws': {
target: 'http://localhost:4430',
ws: true,
},
},
},
};
export default config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.