Last active
April 12, 2017 02:28
-
-
Save linyiru/3357fd0bc6f06b9305f565e7e09af0d6 to your computer and use it in GitHub Desktop.
webpack 2.2.x config file
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 _ = require('lodash') | |
var webpack = require('webpack') | |
var assetsPath = path.join(__dirname, '..', 'public', 'assets') | |
var ExtractTextPlugin = require('extract-text-webpack-plugin') | |
var config = { | |
context: path.join(__dirname, '..'), | |
entry: { | |
application: [ | |
path.join(__dirname, '/javascripts/application.js') | |
] | |
}, | |
output: { | |
path: assetsPath, | |
filename: '[name]-bundle.js', | |
publicPath: 'http://localhost:8080/assets/' | |
}, | |
resolve: { | |
extensions: ['.js', '.json', '.coffee'], | |
alias: { | |
vue: 'vue/dist/vue.js' | |
} | |
}, | |
devtool: 'cheap-module-eval-source-map', | |
devServer: { | |
hot: true, | |
// enable HMR on the server | |
contentBase: assetsPath, | |
// match the output path | |
publicPath: 'http://localhost:8080/assets/' | |
// match the output `publicPath` | |
}, | |
module: { | |
rules: [{ | |
test: require.resolve('jquery'), | |
loader: 'expose?jQuery' | |
}, | |
{ | |
test: require.resolve('jquery'), | |
loader: 'expose?$' | |
}, | |
{ | |
test: /\.js$/, | |
loader: 'babel-loader', | |
exclude: /node_modules/ | |
}, | |
{ | |
test: /\.coffee$/, | |
loader: 'coffee-loader' | |
}, | |
{ | |
test: /\.(woff|woff2|eot|ttf|otf)\??.*$/, | |
loader: 'url-loader?limit=8192&name=[name].[ext]' | |
}, | |
{ | |
test: /\.(jpe?g|png|gif|svg)\??.*$/, | |
loader: 'url-loader?limit=8192&name=[name].[ext]' | |
}, | |
{ | |
test: /\.(sc|c)ss$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: [ | |
'css-loader?sourceMap', | |
'sass-loader' | |
] | |
}) | |
}, | |
{ | |
test: /\.vue$/, | |
loader: 'vue-loader' | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.ProvidePlugin({ | |
$: 'jquery', | |
jQuery: 'jquery' | |
}), | |
new ExtractTextPlugin({ | |
filename: '[name]-bundle.css', | |
allChunks: true | |
}), | |
new webpack.LoaderOptionsPlugin({ | |
debug: true | |
}) | |
] | |
} | |
module.exports = config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment