1 | # Quick Start: Texel CLI
|
2 |
|
3 | The Texel command-line has the following format:
|
4 |
|
5 | ```sh
|
6 | texel [commands] [entry.js] [options]
|
7 | ```
|
8 |
|
9 | Texel has a few _commands_, but for now we will focus on the following three:
|
10 |
|
11 | - `texel create` – Sets up a new project folder
|
12 | - `texel start` – Starts a development server for live-coding
|
13 | - `texel bundle` – Builds your JavaScript and CSS for production
|
14 |
|
15 | Before you begin, ensure you have the latest version of Node.js and npm. For details, see [Installing Node.js and npm](#).
|
16 |
|
17 | # Table of Contents
|
18 |
|
19 | - Your First Project
|
20 | - [`create` – Project Setup](#)
|
21 | - [`start` – Development](#)
|
22 | - [`bundle` – Building for Production](#)
|
23 | - Configuring Your Project
|
24 | - [Editing `npm run` Scripts](#)
|
25 | - [Using a Different CSS Pre-Processor](#)
|
26 | - [Using a Different JavaScript Entry Point](#)
|
27 | - Other Bits
|
28 | - [Installing & Using Texel Globally](#)
|
29 | - [Adding Texel to an Existing Project](#)
|
30 | - [Removing Minification](#)
|
31 |
|
32 | # Your First Project
|
33 |
|
34 | ## `create` – Project Setup
|
35 |
|
36 | First, create a new folder and navigate into it:
|
37 |
|
38 | ```sh
|
39 | # Create a new folder for your app
|
40 | mkdir my-cool-app
|
41 |
|
42 | # Move into that new folder
|
43 | cd my-cool-app
|
44 | ```
|
45 |
|
46 | Next, we can use the [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) command, which comes with npm, to quick start a new project.
|
47 |
|
48 | ```sh
|
49 | npx texel create
|
50 | ```
|
51 |
|
52 | This will automatically install and run the latest version of `texel`, creating a new project based on your current working directory (`my-cool-app`) and stubbing out any necessary files.
|
53 |
|
54 | > ANIMATION OF INSTALL
|
55 |
|
56 | ## `start` – Development
|
57 |
|
58 | After running `texel create`, you'll notice several new files in your project folder. During development, you will typically be editing the following files:
|
59 |
|
60 | - `src/index.js` (JavaScript code)
|
61 | - `src/style.css` (style sheet in CSS)
|
62 | - `app/index.html` (website markup in HTML)
|
63 |
|
64 | To begin development, you will need to run the `start` command via `npm run`. This will ensure we run the correct version of Texel, i.e. the one that is associated with the project you just set up.
|
65 |
|
66 | ```sh
|
67 | npm run start
|
68 | ```
|
69 |
|
70 | This will open the browser to [localhost:9966](#) and start a development server. Now, when you edit and save the `src/index.js`, `src/style.css` and `app/index.html` files, the page will reload the changes automatically.
|
71 |
|
72 | You can use modern JavaScript and CSS syntax in your source code, including `import` statements to split your application into many files and bring in JS/CSS dependencies from [npm](https://www.npmjs.com/package/). Texel will handle all the transpiling/bundling behind the scenes.
|
73 |
|
74 | ## `bundle` – Building for Production
|
75 |
|
76 | When you are ready to release your site, simply run the following command to generate a static web page:
|
77 |
|
78 | ```sh
|
79 | npm run bundle
|
80 | ```
|
81 |
|
82 | This will write `bundle.js` (all your JavaScript) and `main.css` (all your CSS) into the `app/` folder. It will be optimized, transpiled and compressed for faster loading and cross-browser support.
|
83 |
|
84 | Now you can ZIP the `app/` folder and upload it to your favourite hosting service, such as [Neocities](https://neocities.org/). For other ways of publishing a web page, see the [Publishing your first website](#) guide.
|