Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 11, 2017
0 parents commit cc0e5b1
Show file tree
Hide file tree
Showing 9 changed files with 3,689 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.DS_Store
node_modules
public/bundle.*
package-lock.json
66 changes: 66 additions & 0 deletions README.md
@@ -0,0 +1,66 @@
# svelte app

This is a project template for [Svelte](https://svelte.technology) apps. It lives at https://github.com/sveltejs/template-webpack.

To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):

```bash
npm install -g degit # you only need to do this once

degit sveltejs/template-webpack svelte-app
cd svelte-app
```

*Note that you will need to have [Node.js](https://nodejs.org) installed.*


## Get started

Install the dependencies...

```bash
cd svelte-app
npm install
```

...then start [Rollup](https://rollupjs.org):

```bash
npm run dev
```

Navigate to [localhost:8080](http://localhost:8080). You should see your app running. Edit a component file in `src`, save it, and the page should reload with your changes.


## Deploying to the web

### With [now](https://zeit.co/now)

Install `now` if you haven't already:

```bash
npm install -g now
```

Then, from within your project folder:

```bash
now
```

As an alternative, use the [Now desktop client](https://zeit.co/download) and simply drag the unzipped project folder to the taskbar icon.

### With [surge](https://surge.sh/)

Install `surge` if you haven't already:

```bash
npm install -g surge
```

Then, from within your project folder:

```bash
npm run build
surge public
```
16 changes: 16 additions & 0 deletions package.json
@@ -0,0 +1,16 @@
{
"name": "svelte-app",
"version": "1.0.0",
"devDependencies": {
"cross-env": "^5.1.1",
"serve": "^6.4.1",
"svelte": "^1.46.1",
"svelte-loader": "^2.1.0",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7"
},
"scripts": {
"build": "cross-env NODE_ENV=production webpack",
"dev": "webpack-dev-server"
}
}
61 changes: 61 additions & 0 deletions public/global.css
@@ -0,0 +1,61 @@
html, body {
position: relative;
width: 100%;
height: 100%;
}

body {
color: #333;
margin: 0;
padding: 8px;
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

a {
color: rgb(0,100,200);
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

a:visited {
color: rgb(0,80,160);
}

label {
display: block;
}

input, button, select, textarea {
font-family: inherit;
font-size: inherit;
padding: 0.4em;
margin: 0 0 0.5em 0;
box-sizing: border-box;
border: 1px solid #ccc;
border-radius: 2px;
}

input:disabled {
color: #ccc;
}

input[type="range"] {
height: 0;
}

button {
background-color: #f4f4f4;
outline: none;
}

button:active {
background-color: #ddd;
}

button:focus {
border-color: #666;
}
16 changes: 16 additions & 0 deletions public/index.html
@@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<meta charset='utf8'>
<meta name='viewport' content='width=device-width'>

<title>Svelte app</title>

<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='bundle.css'>
</head>

<body>
<script src='bundle.js'></script>
</body>
</html>
7 changes: 7 additions & 0 deletions src/App.html
@@ -0,0 +1,7 @@
<h1>Hello {{name}}!</h1>

<style>
h1 {
color: red;
}
</style>
12 changes: 12 additions & 0 deletions src/main.js
@@ -0,0 +1,12 @@
import App from './App.html';

const app = new App({
target: document.body,
data: {
name: 'world'
}
});

window.app = app;

export default app;
36 changes: 36 additions & 0 deletions webpack.config.js
@@ -0,0 +1,36 @@
const { readFileSync } = require('fs');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

const prod = process.env.NODE_ENV === 'production';

module.exports = {
entry: {
bundle: ['./src/main.js']
},
resolve: {
extensions: ['.js', '.html']
},
output: {
path: __dirname + '/public',
filename: '[name].js',
chunkFilename: '[name].[id].js'
},
module: {
rules: [
{
test: /\.html$/,
exclude: /node_modules/,
use: 'svelte-loader'
}
]
},
plugins: prod ? [
new webpack.optimize.ModuleConcatenationPlugin(),
new UglifyJSPlugin()
] : [],
devServer: {
contentBase: './public'
},
devtool: prod ? false : 'inline-source-map'
};

0 comments on commit cc0e5b1

Please sign in to comment.