sveltejs / template-webpack

Template for building basic Svelte applications with webpack
300 stars 118 forks source link

Change how dependencies are organized by default #32

Closed pyritewolf closed 3 years ago

pyritewolf commented 3 years ago

Hey guys! I'm new to the community, so what I'm saying might be nonesense 😅 but running this template generated the following package.json for me:

{
  "name": "svelte-app",
  "version": "1.0.0",
  "devDependencies": {
    "cross-env": "^5.2.0",
    "css-loader": "^2.1.1",
    "mini-css-extract-plugin": "^0.6.0",
    "serve": "^11.0.0",
    "style-loader": "^0.23.1",
    "svelte": "^3.0.0",
    "svelte-loader": "2.13.3",
    "webpack": "^4.30.0",
    "webpack-cli": "^3.3.0",
    "webpack-dev-server": "^3.3.1"
  },
  "scripts": {
    "build": "cross-env NODE_ENV=production webpack",
    "dev": "webpack-dev-server --content-base public"
  }
}

Which was all nice and well until I tried to make a prod build (npm install --production && npm run build) and I realized all the dependencies are configured as devDependencies, even some that shouldn't be. After some trial and error, these are the minimum packages that I had to move to dependencies for things to work properly on my prod build:

{
  "name": "svelte-app",
  "version": "1.0.0",
  "dependencies": {
    "cross-env": "^5.2.0",
    "css-loader": "^2.1.1",
    "mini-css-extract-plugin": "^0.6.0",
    "svelte": "^3.0.0",
    "svelte-loader": "2.13.3",
    "webpack": "^4.30.0",
    "webpack-cli": "^3.3.0"
  },
  "devDependencies": {
    "serve": "^11.0.0",
    "style-loader": "^0.23.1",
    "webpack-dev-server": "^3.3.1"
  },
  "scripts": {
    "build": "cross-env NODE_ENV=production webpack",
    "dev": "webpack-dev-server --content-base public"
  }
}