Created
December 6, 2015 15:30
-
-
Save shunjikonishi/d5b814aa09f819da37ee to your computer and use it in GitHub Desktop.
webpack
This file contains 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
module.exports = function (grunt) { | |
'use strict'; | |
require('load-grunt-tasks')(grunt); | |
require('time-grunt')(grunt); | |
var webpack = require("webpack"); | |
var ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
var proxyOptionsLocal = { | |
target: "localhost:9000", | |
host: "http://localhost:9000" | |
}; | |
var proxyOptionsDev = { | |
target: DEVSERVER_PROXY_URL, | |
host: DEVSERVER_PROXY_HOST | |
}; | |
var proxyOptionsProd = { | |
target: "myapp-dev.herokuapp.com", | |
host: "https://myapp-dev.herokuapp.com" | |
}; | |
var proxyOptions = proxyOptionsLocal; | |
grunt.initConfig({ | |
webpack: { | |
users: { | |
entry: { | |
"bundle": "./client/users/entry.js", | |
"bundle.test": "./client/users/entry.test.js" | |
}, | |
output: { | |
path: "public/users/js/", | |
filename: "[name].js" | |
}, | |
resolve: [".js", ".jsx"], | |
module: { | |
loaders: [ | |
{ | |
test: /\.scss$|\.css$/, | |
loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader") | |
}, | |
{ | |
test: /\.jsx$/, | |
loader: "jsx-loader" | |
}, | |
{ | |
test: /\.(ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: "file-loader?name=../fonts/[name].[ext]" | |
}, | |
{ | |
test: /\.(jpe?g|png|gif)?$/, | |
loader: "file-loader?name=../images/[name].[ext]" | |
} | |
] | |
}, | |
plugins: [ | |
new ExtractTextPlugin("../css/bundle.css") | |
], | |
node: { | |
net : 'empty', | |
dns : 'empty' | |
} | |
} | |
}, | |
"webpack-dev-server": { | |
users: { | |
port: 9000, | |
host: "localhost", | |
contentBase: "./client/dev-server", | |
publicPath: "/assets/users/js/", | |
keepAlive: true, | |
historyApiFallback: true, | |
hot: true, | |
progress: false, | |
proxy: { | |
"/i18n/*": proxyOptions, | |
"/auth/*": proxyOptions, | |
"/assets/*": proxyOptions, | |
"/api/*": proxyOptions | |
}, | |
webpack: { | |
entry: { | |
app: ['webpack/hot/dev-server', "./client/users/entry.js"], | |
}, | |
output: { | |
path: "./client/dev-server/assets/users/js/", | |
filename: "bundle.js", | |
}, | |
resolve: [".js", ".jsx"], | |
module: { | |
loaders: [ | |
{ | |
test: /\.css$/, | |
loader: "style-loader!css-loader" | |
}, | |
{ | |
test: /\.scss$/, | |
loader: "style-loader!css-loader!sass-loader" | |
}, | |
{ | |
test: /\.jsx$/, | |
loader: "jsx-loader" | |
}, | |
{ | |
test: /\.(ttf|eot|svg|woff|woff2)(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: "file-loader?name=/fonts/[name].[ext]" | |
}, | |
{ | |
test: /\.(jpe?g|png|gif)?$/, | |
loader: "file-loader?name=/images/[name].[ext]" | |
} | |
] | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin() | |
], | |
devtool: "eval", | |
debug: true, | |
node: { | |
net : 'empty', | |
dns : 'empty' | |
} | |
} | |
} | |
} | |
}); | |
grunt.registerTask('withProd', [ | |
proxyOptions = proxyOptionsProd; | |
'webpack-dev-server' | |
]); | |
grunt.registerTask('withDev', [ | |
proxyOptions = proxyOptionsDev; | |
'webpack-dev-server' | |
]); | |
grunt.registerTask('withLocal', [ | |
proxyOptions = proxyOptionsLocal; | |
'webpack-dev-server' | |
]); | |
grunt.registerTask('heroku', [ | |
'webpack' | |
]); | |
grunt.registerTask('default', [ | |
'webpack' | |
]); | |
}; |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>Code-Check</title> | |
<meta name="description" content="Example Description"> | |
<meta name="viewport" content="initial-scale=1.0,width=device-width"> | |
<script src="http://localhost:9000/webpack-dev-server.js"></script> | |
<script src="/assets/users/js/bundle.js" type="text/javascript"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment