mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-22 07:05:24 +00:00
workaround weird webpack(?) bug by not deleting old files
This commit is contained in:
@@ -154,10 +154,9 @@ export default async function dev(src: string, dir: string) {
|
|||||||
|
|
||||||
deferreds.client = deferred();
|
deferreds.client = deferred();
|
||||||
|
|
||||||
// TODO print message
|
// TODO we should delete old assets. due to a webpack bug
|
||||||
fs.readdirSync(path.join(dir, 'client')).forEach(file => {
|
// i don't even begin to comprehend, this is apparently
|
||||||
fs.unlinkSync(path.join(dir, 'client', file));
|
// quite difficult
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
compilers.client.watch({}, (err: Error, stats: any) => {
|
compilers.client.watch({}, (err: Error, stats: any) => {
|
||||||
@@ -196,7 +195,7 @@ export default async function dev(src: string, dir: string) {
|
|||||||
times.serviceworker_start = Date.now();
|
times.serviceworker_start = Date.now();
|
||||||
});
|
});
|
||||||
|
|
||||||
compilers.client.watch({}, (err: Error, stats: any) => {
|
compilers.serviceworker.watch({}, (err: Error, stats: any) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
// TODO notify client
|
// TODO notify client
|
||||||
} else if (stats.hasErrors()) {
|
} else if (stats.hasErrors()) {
|
||||||
@@ -209,7 +208,6 @@ export default async function dev(src: string, dir: string) {
|
|||||||
|
|
||||||
const serviceworker_info = stats.toJson();
|
const serviceworker_info = stats.toJson();
|
||||||
fs.writeFileSync(path.join(dir, 'serviceworker_info.json'), JSON.stringify(serviceworker_info, null, ' '));
|
fs.writeFileSync(path.join(dir, 'serviceworker_info.json'), JSON.stringify(serviceworker_info, null, ' '));
|
||||||
// TODO trigger reload?
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
let source;
|
let source;
|
||||||
|
|
||||||
|
console.log('!!!! hmr client');
|
||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
if (module.hot.status() === 'idle') {
|
if (module.hot.status() === 'idle') {
|
||||||
module.hot.check(true).then(modules => {
|
module.hot.check(true).then(modules => {
|
||||||
|
|||||||
@@ -12,12 +12,6 @@ import { Route, Template } from '../interfaces';
|
|||||||
|
|
||||||
const dev = isDev();
|
const dev = isDev();
|
||||||
|
|
||||||
type Assets = {
|
|
||||||
index: string;
|
|
||||||
service_worker: string;
|
|
||||||
client: Record<string, string>;
|
|
||||||
}
|
|
||||||
|
|
||||||
type RouteObject = {
|
type RouteObject = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'page' | 'route';
|
type: 'page' | 'route';
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export default {
|
|||||||
output: () => {
|
output: () => {
|
||||||
return {
|
return {
|
||||||
path: `${dest}/client`,
|
path: `${dest}/client`,
|
||||||
filename: '[name].[hash].js',
|
filename: '[hash]/[name].js',
|
||||||
chunkFilename: '[name].[id].[hash].js',
|
chunkFilename: '[hash]/[name].[id].js',
|
||||||
publicPath: '/client/'
|
publicPath: '/client/'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
path: `${dest}`,
|
path: `${dest}`,
|
||||||
filename: '[name].js',
|
filename: '[name].js',
|
||||||
chunkFilename: '[name].[id].[hash].js',
|
chunkFilename: '[hash]/[name].[id].js',
|
||||||
libraryTarget: 'commonjs2'
|
libraryTarget: 'commonjs2'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user