You'll find v4 here.
A semi-opinionated build tool for frontend projects. Use it to lint, bundle and test your script, style and asset files.
Contributions welcome. Please report any issues.
- abstract the tooling so that:
- we setup new projects more quickly (e.g. no need for everyone to spend time researching specific tools and best practice for setting them up, just use
tradie- we've done all the research and testing for you!) - we spend less time maintaining tooling (e.g. no need to keep all the tools up to date - just use
tradie, a single dependency) - we are less impacted when we change tooling (e.g. no need to re-write all the tooling in your project -
tradiewill abstract (most of) the differences between the old and new tooling) - the project can still override some of the tools
- cater to common application types
- we setup new projects more quickly (e.g. no need for everyone to spend time researching specific tools and best practice for setting them up, just use
Create React App is a great tool and we'd highly recommend
giving it a go!
However
create-react-app is tailored to a specific use-case and doesn't support CSS pre-processing (e.g. SASS), multiple
targets or UniversalJS applications. Tradie supports SASS and a number of common application types.
npm install --save-dev tradie
-
Setup your project:
src/ index.js index.test.jsUse a generator rather than doing it manually! e.g. generator-tradie-react.
-
Build your project with:
npm run build -
Test your project with:
npm run test
src/
index.js
index.test.js
dest/
rev-manifest.json
index.abcdefg.js
vendor.abcdefg.js
tmp/
abcdefg.json.gzip
vendor-manifest.json
The directory where your application source code lives.
Place all your script, style, asset and test files here.
The directory where your application artifacts are generated.
Don't change anything here! It'll be overwritten next time you build.
The directory where temporary files are generated.
Don't change anything here! It'll be overwritten next time you build.
Tradie works out-of-the-box with no configuration. However, Tradie can be configured to support additional
functionality by placing a tradie.config.js file in the project root. The file must export an object,
or a function that returns an object.
The default configuration for Tradie looks like this:
module.exports = {
script: {
bundles: ['index.js'],
vendors: [],
extensions: ['.js']
},
style: {
extensions: ['.css', '.scss']
},
asset: {
extensions: [
'.jpeg', '.jpg', '.gif', '.png', '.svg',
'.woff', '.ttf', '.eot'
]
},
eslint: {},
babel: {},
webpack: {},
plugins: []
};A list of module paths that will be bundled into script files.
Module paths are relative to your project's src directory.
Optional. An
arrayofstrings. Defaults to['index.js'].
Example: Multiple bundles
You can create multiple bundles. Dependencies shared between all of the bundles will be bundled into a script file
named
common.js.
module.exports = {
script: {
bundles: ['campaign/abc/index.js', 'campaign/xyz/index.js']
}
};Example: UniversalJS bundles
You can create a bundle to run on NodeJS by naming your bundle server. Use this when you're sharing the bulk of
your app code across both your server and client.
module.exports = {
script: {
bundles: ['server.js', 'client.js']
}
};A list of modules that will be bundled into a script file named vendor.js.
Optional. An
arrayofstrings. Defaults to[].
Example: Long-term-caching
Bundle infrequently changing modules. These bundles usually make up a significant portion of your app and with long-term-caching they won't need to be (re)downloaded by the browser each time your app is deployed.
module.exports = {
script: {
vendors: ['react', 'react-dom']
}
};A list of extensions for script files.
Optional. An
arrayofstrings. Defaults to['.js].
Example: Require script files ending in
.jsxwithout specifying the extension
Additional file extensions can be supported for parsing and requiring script files.
module.exports = {
script: {
extensions: ['.js', '.jsx']
}
};A list of extensions for style files.
Optional. An
arrayofstrings. Defaults to['.css', '.scss'].
A list of extensions for asset files.
Optional. An
arrayofstrings. Defaults to['.jpeg', '.jpg', '.gif', '.png', '.svg', '.woff', '.ttf', '.eot'].
Configuration used for linting. See Configuring ESLint.
Optional. An
object. Defaults to the contents of your.eslintrcfile.
Configuration used for transpiling. See Options.
Optional. An
object. Defaults to the contents of your.babelrcfile.
Additional configuration passed to webpack. See Configuration.
Optional. An
object. Defaults to{}.
Warning: Avoid using this escape hatch where possible, you'll be more susceptible to breaking changes when
webpackis updated.
A list of plugins that extend tradie to provide additional functionality.
Optional. An
arrayoffunctions. Defaults to[].
Example: Livereload
var livereload = require('tradie-plugin-livereload');
module.exports = {
plugins: [livereload()]
};Remove bundled script, style and asset files.
tradie clean
Removes all files from the dest directory.
Lint script files.
tradie lint [glob...]
Uses eslint to lint script files in the src directory.
globs are relative to the src directory.
Example: Run linting rules on a subset of script files
tradie lint "components/**" "containers/**"Bundle script, style and asset files.
tradie build --watch --optimize
Uses webpack to bundle script, style and asset files.
Use the --watch flag to re-bundle script and style files whenever they change.
Use the --optimize flag to optimize script, style and asset files, including minification, dead-code removal, file
hashing etc.
Test script files.
tradie test --watch [glob...]
Uses webpack to bundle test files and runs the generated bundle with mocha.
Use the --watch flag to re-test script files whenever they change.
globs are relative to the src directory.
Example: Run tests on a subset of script files
tradie test "components/**" "containers/**"