Created
November 23, 2015 00:04
-
-
Save cymen/9aec78c717c352ea0dc2 to your computer and use it in GitHub Desktop.
webpack config with css, etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var commonLoaders = [ | |
{ | |
test: /\.css$/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!autoprefixer-loader?browsers=last 3 versions') | |
}, { | |
test: /\.less$/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!autoprefixer-loader?browsers=last 3 versions!less-loader') | |
}, { | |
test: /\.sass/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!autoprefixer-loader?browsers=last 3 versions!sass-loader') | |
}, { | |
test: /\.scss/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!autoprefixer-loader?browsers=last 3 versions!sass-loader') | |
}, | |
{ | |
test: /\.js$/, | |
loaders: ['babel-loader'], | |
exclude: /node_modules/ | |
}, { | |
test: /\.json$/, | |
loaders: ['json-loader'] | |
} | |
]; | |
var assetsPath = path.join(__dirname, '/dist'); | |
var publicPath = '/app/webpack/dist/'; | |
module.exports = { | |
name: 'browser', | |
entry: [ | |
path.join(__dirname, '/node_modules/babel-core/polyfill.js'), | |
path.join(__dirname, '/src/MyApp.js') | |
], | |
output: { | |
path: assetsPath, | |
publicPath: publicPath, | |
filename: 'bundle.js' | |
}, | |
module: { | |
loaders: commonLoaders.concat([{ | |
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: 'url-loader?limit=10000&mimetype=application/font-woff' | |
}, { | |
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: 'file-loader' | |
}, { | |
test: /\.gif/, | |
loader: 'url-loader?limit=10000&mimetype=image/gif' | |
}, { | |
test: /\.jpg/, | |
loader: 'url-loader?limit=10000&mimetype=image/jpg' | |
}, { | |
test: /\.png/, | |
loader: 'url-loader?limit=10000&mimetype=image/png' | |
}, { | |
test: /\.jsx?$/, | |
exclude: /node_modules/, | |
loader: 'babel-loader', | |
query: { | |
cacheDirectory: true | |
} | |
}]) | |
}, | |
plugins: [ | |
new ExtractTextPlugin('bundle.css', { | |
allChunks: true | |
}) | |
] | |
}; |
Note the package.json is off a branch that is WIP on doing some server-side rendering so it has some things in it temporarily like express.
Thanks for taking the time to put this together! How are you exactly using this with Rails? Or is your front end separated out?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
package.json looks like: