Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

trailsjs/trailpack-webpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

43 Commits

Repository files navigation

trailpack-webpack

Gitter NPM version Linux + OSX Build Status Windows Build Status Code Climate Follow @trailsjs on Twitter

Webpack asset pipeline trailpack for Trails.

1. Install

$ npm install trailpack-webpack --save

2. Configure

a. Set your environment.

By default, Trails (and express) sets NODE_ENV=development. In this setting, webpack will watch for changes in the directories you specify in your config/webpack.js.

NODE_ENV webpack mode description
development webpack.watch() Rebuilds on file changes during runtime
staging or production webpack.run() Build bundle once on load.

b. Configure Webpack

This trailpack includes basic Webpack Configuration. Below is a more complete example of using webpack to compile a React.js application located in assets/js/.

// config/webpack.js
module.exports = {
 entry: [
 './client/js/app.js'
 ],
 output: {
 path: './public',
 filename: 'app.js',
 publicPath: ''
 },
 plugins: [
 new HtmlWebpackPlugin({
 title: 'Trails Application'
 }),
 new webpack.HotModuleReplacementPlugin(),
 new webpack.NoErrorsPlugin()
 ],
 module: {
 loaders: [{
 test: /\.js$/,
 loader: 'babel',
 exclude: /node_modules/,
 query: {
 presets: [ 'react', 'es2015', 'stage-0' ]
 }
 }, {
 test: /\.css$/,
 loader: 'style-loader!css-loader'
 }, {
 test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
 loader: 'file-loader?name=fonts/[name].[ext]'
 }, {
 test: /\.(png|jpg)$/,
 loader: require.resolve('url-loader')
 }]
 }
}

3. Start!

$ npm start

Contributing

We love contributions! Please check out our Contributor's Guide for more information on how our projects are organized and how to get started.

License

MIT

About

πŸ“¦ Webpack Trailpack.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /