强制 Snowpack 构建到一个文件中

问题描述

Snowpack dev 非常酷 - 但根据我的需要,我需要将所有 js/css/images 完全打包到 one bundle.js 文件中。没有大块或其他任何东西。我曾尝试在 snowpack.config.jsplugins 中使用以下 webpack 插件配置:

[
  "@snowpack/plugin-webpack",{
    outputPattern: {
      js: "bundle.js",css: "bundle.css",},extendConfig: (config) => {
      delete config.optimization.splitChunks;
      delete config.optimization.runtimeChunk;
      return config;
    },],

这导致创建这两个文件:bundle.jsbundle.css

是否有一种简单的方法:

  1. 只将所有内容打包到 build.js 中,而没有 css 文件?
  2. 是否自动删除仍留在构建文件夹中的所有其他文件(__snowpack__web_modules、源文件)?

解决方法

修改 coreos: update: reboot-strategy: off units: - name: "docker.service" command: "start" - name: "iptables-restore.service" command: "start" - name: "setup-sysctl.service" command: "start" content: | [Unit] Description=Set sysctl Before=docker.service [Service] Restart=on-failure RestartSec=5 ExecStart=/bin/sh -c 'ulimit -Hn 100000 && ulimit -Hs 50000' - name: amazon-ssm-agent.service enabled: true contents: | [Unit] Description=Amazon SSM Agent After=docker.service Requires=docker.service [Service] Restart=always RestartSec=10s ExecStartPre=/usr/bin/docker pull vamshisiddarth/amazon-ssm-agent ExecStart=/bin/sh -c "/usr/bin/docker run -d -v /var/run/docker.sock:/var/run/docker.sock --net=host -p=80:80 --restart unless-stopped --name amazon-ssm-agent --device=/dev/ttyS0 -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd -v /etc/sudoers.d:/etc/sudoers.d vamshisiddarth/amazon-ssm-agent" ExecStop=/usr/bin/docker stop amazon-ssm-agent ExecStop=-/usr/bin/docker kill amazon-ssm-agent [Install] WantedBy=multi-user.target 如下:

snowpack.config.js

const path = require('path'); module.exports = { ... [ '@snowpack/plugin-webpack',{ outputPattern: { js: "index.js",css: "index.css",},extendConfig: config => { delete config.optimization.splitChunks; delete config.optimization.runtimeChunk; config.module.rules[0] = { test: /\.js$/,exclude: /node_modules/,use: [ { loader: 'babel-loader',options: { presets: ['@babel/preset-env'] } },{ loader: path.resolve(__dirname,'./node_modules/@snowpack/plugin-webpack/plugins/import-meta-fix.js') } ] } return config; } } ],... 的输出:

npm run build

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...