foolish
v1.4.0
Published
Another foolish frontend build script.
Downloads
38
Readme
A foolish front-end building script
Building is not fun, especially so many choices (gulp, webpack, systemjs, ...) to make a building system for you (or your team).
So I decide to jump out of this shit pit. Here is my solution.
Concept
- Simpler is better.
- Convention over configuration. (Actully, there is nothing you can change)
Should I use this?
This build script is for single page app. It just concat all project scripts to one, and compile a less style. No framework specified.
Installation
npm install -g foolish
How to use
- Building project:
foolish
- Start a dev server:
foolish server
Document
Filename conventions
Any directory is a valid foolish project, even if it's empty. Some filename is special but not required:
index.html
: this is the landing page.main.js
: this script will be at the top in combiled script.run.js
: this script will be at the ned in combiled script.main.less
: write your less style here.app.js
: only use this inindex.html
, your project should not have this file, it's combined output script filename.app.css
: only use this inindex.html
, your project should not have this file, it's compile style filename.
Here is a basic web page project which contains script and stylesheet:
mkdir my-foolish-project && cd my-follish-project
.echo '<link href="app.css" rel="stylesheet"></link>' > index.html
.echo '<script src="app.js" type="text/javascript"></script>' >> index.html
.touch main.js
.touch main.less
.
Development Server
Use command foolish server
, a small http server will start listening on port 3000.
Look at the initialize step, I think you already realized there is no app.js
or app.css
. Those files are virtual, which generated by development server or building script.
app.js
will load all your scripts, app.css
is generated from main.less
.
You can use --port
parameter to change the server port.
Building
Just run foolish
under your project directory, then you will get a dist
directory which contains what you want.
The building prosess is simple:
- Concat all
.js
files in your project directory (exceptnode_modules
) todist/app.js
.main.js
will at head andrun.js
will be the last. - Compile
main.less
todist/app.css
. - Find assets which refrenced by
index.html
anddist/app.css
, copy them todist
directory.
Other scripts
- foolish-angular: angular template cache support.
- foolish-rev: assets reversion tool.
- foolish-prefix: replace url prefix.
FAQ
Q: How can I import 3rd-party modules?
A: Just create a <script>
tag in index.html
to reference a script file. The file location can be in internect (like CDN server) or just a local dependency in node_modules
(npm install
is welcome).
Q: Can I add some pre-process plugin like coffee or babel?
A: Sure but not in foolish
. You can do this by shell command.
Contribution
PR is welcome. I'll very happy if someone tell me some feature is useless and can be drop out.
License
MIT