Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #225 from meteor/build-tool-updates-for-1.3
Browse files Browse the repository at this point in the history
Updates to the build article content for 1.3
  • Loading branch information
Tom Coleman committed Mar 1, 2016
2 parents 092e615 + c0ff01b commit b381d25
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions content/build-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ One difference between pre-published packages and local app packages is that the

<h4 id="npm-adding">Adding packages to your app</h4>

Meteor 1.3 will have seamless integration with NPM, and you will be able to simply `npm install` these packages into your app directory. Until then, the easiest way to use NPM packages in your app is [`meteorhacks:npm`](https://atmospherejs.com/meteorhacks/npm).
To install an NPM package into your app, you can simply run NPM's (we recommend using NPM3, although other versions of NPM should work with Meteor also) standard install command:

```
npm install --save <package name>
```

If the package is just a development dependency (i.e. it's used for testing, linting or the like), then you can use `--save-dev`. That way if you have some kind of build script, it can do `npm install --production` and avoid installing packages it doesn't need.

Note that your colleagues will need to run `npm install` when they update their version of the app to get the NPM dependency. The Meteor tool will warn them if they fail to do so.

<h4 id="npm-searching">Searching for packages</h4>

Expand Down Expand Up @@ -175,7 +183,10 @@ sendTextMessage() {

<h3 id="client-npm">NPM on the client</h3>

NPM started as a package manager for Node.js, but is quickly becoming one of the most popular places to publish client-side modules as well. Meteor 1.3 will include built-in support for bundling NPM modules on the client, but in the meantime the best option is to use the [`cosmos:browserify`](https://atmospherejs.com/cosmos/browserify) package to bundle these modules. Since one of the most common scenarios is using React components from NPM, read about how to do this in the [React in Meteor guide](http://react-in-meteor.readthedocs.org/en/latest/client-npm/).
NPM started as a package manager for Node.js, but is quickly becoming one of the most popular places to publish client-side modules as well. Thanks to Meteor's built in client-side support for [ES2015 modules](app-structure.html#modules), you can use appropriate NPM packages on the client easily, simply by installing the package as usual and `import`-ing from it from a client-side file.

For example, in the [React article](react.html#react-router) we discuss how to use the [React Router](https://github.com/rackt/react-router) in the client side of an app with a few simple commands.


<h2 id="javascript-transpilation">JavaScript transpilation</h2>

Expand Down Expand Up @@ -302,7 +313,31 @@ Currently, Meteor doesn't have a separate build step for post-processing CSS, so

<h3 id="juliancwirko-postcss">juliancwirko:postcss</h3>

Use the package [juliancwirko:postcss](https://atmospherejs.com/juliancwirko/postcss) to your app to enable PostCSS for your Meteor app. It's not completely trivial to set it up, and we hope to make support for PostCSS a more core part of Meteor in the future. Read the documentation for the package to get the steps to add it to your app; we won't reproduce the instructions here since they might change in future versions.
Use the package [juliancwirko:postcss](https://atmospherejs.com/juliancwirko/postcss) to your app to enable PostCSS for your Meteor app. To do so, we remove the standard CSS minifier and replace it with the postcss package:

```
meteor remove standard-minifiers
meteor add juliancwirko:postcss
# We still want Meteor's built in JS minifiers
meteor add standard-minifiers-js
```
Then we can install any NPM CSS processing packages that we'd like to use and reference them from a `postcss` section of our `package.json`. In the Todos example app, we use `autoprefixer` package to increase browser support:

```
{
"devDependencies": {
"autoprefixer": "^6.3.1"
},
"postcss": {
"plugins": {
"autoprefixer": {"browsers": ["last 2 versions"]}
}
}
}
```

After doing the above, you'll need to ensure you `npm install` and restart the `meteor` process running your app to make sure the PostCSS system has had a chance to set itself up.
<h2 id="minification">Minification</h2>
Expand Down

0 comments on commit b381d25

Please sign in to comment.