Last active
March 13, 2019 19:16
-
-
Save budarin/c41a942684f90d7fc10ac2531dfcbeb2 to your computer and use it in GitHub Desktop.
After recompiling copy-webpack-plugin does not update assets-manifest.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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