This repository has been archived by the owner on Jul 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwebpack.config.js
80 lines (65 loc) · 1.97 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Webpack config with Babel, Sass and PostCSS support.
*/
var PROD = process.env.NODE_ENV === 'production'
var DEBUG = !PROD
var webpack = require('webpack')
var join = require('path').join
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var LiveReloadPlugin = DEBUG ? require('webpack-livereload-plugin') : null
module.exports = {
cache: true,
context: __dirname,
entry: {
// JavaScript
'javascripts/webpack/app': './app/webpack/js/app.js',
// Stylesheets
'stylesheets/webpack/app': './app/webpack/css/app.js',
},
output: {
path: join(__dirname, 'vendor/assets'),
filename: '[name].js',
pathinfo: DEBUG ? true : false,
devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]'
},
module: {
loaders: [
{
test: /\.scss$/,
loader: DEBUG
? ExtractTextPlugin.extract('style-loader', 'css-loader?-url&sourceMap&importLoaders=1!postcss-loader?sourceMap=inline!sass-loader?sourceMap')
: ExtractTextPlugin.extract('style-loader', 'css-loader?-url!postcss-loader!sass-loader')
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loaders: [ 'babel-loader' ],
query: {
cacheDirectory: true
}
},
],
},
resolve: {
extensions: ['', '.js', '.jsx']
},
postcss: [
require('autoprefixer')(),
require('postcss-asset-url-rails')()
],
sassLoader: {
includePaths: join(__dirname, 'node_modules'),
outputStyle: DEBUG ? 'nested' : 'compressed'
},
plugins: [
// allChunks will preserve source maps
new ExtractTextPlugin('[name].css.erb', { allChunks: true }),
// Ignore locales because it's around 400kb
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
].concat(DEBUG ? [
new LiveReloadPlugin({ appendScriptTag: true })
] : []),
// Best trade-off with compatibility and speed
devtool: DEBUG ? 'cheap-module-eval-source-map' : undefined,
debug: DEBUG ? true : false
}