mirror of
https://github.com/danbulant/nollup-bug
synced 2026-05-19 04:18:40 +00:00
minimum example
This commit is contained in:
commit
c3a301a138
6 changed files with 70 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
pnpm-lock.yaml
|
||||
5
.nolluprc.js
Normal file
5
.nolluprc.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
contentBase: 'public',
|
||||
port: 9001,
|
||||
hot: true
|
||||
};
|
||||
15
package.json
Normal file
15
package.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"scripts": {
|
||||
"clean": "shx rm -rf dist",
|
||||
"start": "nollup -c --environment NODE_ENV:development",
|
||||
"build": "npm run clean && rollup -c --environment NODE_ENV:production"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nollup": "^0.15.0",
|
||||
"rollup": "^2.38.5",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-static-files": "0.0.1",
|
||||
"rollup-plugin-terser": "^5.1.1",
|
||||
"shx": "^0.3.2"
|
||||
}
|
||||
}
|
||||
16
public/index.html
Normal file
16
public/index.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Barebones</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script>
|
||||
const worker = new SharedWorker("/sharedworker.js");
|
||||
worker.port.start();
|
||||
worker.port.postMessage("test");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
27
rollup.config.js
Normal file
27
rollup.config.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import node_resolve from 'rollup-plugin-node-resolve';
|
||||
import static_files from 'rollup-plugin-static-files';
|
||||
import { terser } from 'rollup-plugin-terser';
|
||||
|
||||
let config = {
|
||||
input: './src/sharedworker.js',
|
||||
output: {
|
||||
dir: 'dist',
|
||||
format: 'esm',
|
||||
entryFileNames: '[name].js',
|
||||
assetFileNames: '[name][extname]'
|
||||
},
|
||||
plugins: [
|
||||
node_resolve()
|
||||
]
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
config.plugins = config.plugins.concat([
|
||||
static_files({
|
||||
include: ['./public']
|
||||
}),
|
||||
terser()
|
||||
]);
|
||||
}
|
||||
|
||||
export default config;
|
||||
5
src/sharedworker.js
Normal file
5
src/sharedworker.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
self.port.start();
|
||||
self.port.addEventListener("message", (...args) => {
|
||||
console.log("message", ...args);
|
||||
});
|
||||
Loading…
Reference in a new issue