Last active
March 3, 2020 03:29
-
-
Save flyingzl/42e61de92490219f2c48 to your computer and use it in GitHub Desktop.
Revisions
-
flyingzl revised this gist
Oct 28, 2015 . No changes.There are no files selected for viewing
-
flyingzl created this gist
Oct 28, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ { "name": "think-in-react", "version": "1.0.0", "description": "", "main": "app.js", "scripts": { "dev": "webpack-dev-server --devtool source-maps --hot --progress --colors --content-base .", "build": "set NODE_ENV=production&&webpack -pd" }, "browserify": { "transform": [ [ "reactify", { "harmony": true } ] ] }, "author": "flyingzl", "license": "MIT", "devDependencies": { "babel-core": "^5.8.29", "babel-loader": "^5.3.2", "css-loader": "^0.21.0", "exports-loader": "^0.6.2", "extract-text-webpack-plugin": "^0.8.2", "file-loader": "^0.8.4", "jsx-loader": "^0.13.2", "less-loader": "^2.2.1", "react": "^0.14.0", "react-addons-css-transition-group": "^0.14.0", "react-addons-pure-render-mixin": "^0.14.0", "react-dom": "^0.14.0", "react-hot-loader": "^1.3.0", "style-loader": "^0.13.0", "uglify-js": "^2.5.0", "url-loader": "^0.5.6", "webpack": "^1.12.2", "webpack-dev-server": "^1.12.1" } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,105 @@ var path = require("path"), webpack = require("webpack"); var node_modules = path.resolve(__dirname, 'node_modules'); var ExtractTextPlugin = require("extract-text-webpack-plugin"); var config = { addVendor: function(name, path) { this.resolve.alias[name] = path; this.module.noParse.push(new RegExp('^' + name + '$')); }, addLoader: function(loader){ this.module.loaders.push(loader); }, addPlugin: function(plugin){ this.plugins.push(plugin); }, entry: { app: [ path.resolve(__dirname, "src/app.js") ], vendors: ["react", "react-dom"] }, resolve: { alias: {} }, output: { path: path.join(__dirname, 'dist'), publicPath: '/static/', filename: "bundle.js" }, clearBeforeBuild: true, plugins: [ new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js') ], module: { noParse: [], loaders: [{ test: /\.js$/, loader: 'babel', include: path.join(__dirname, 'src') }, { test: /\.(png|jpg)$/, loader: "url-loader?limit=10240" }, { test: require.resolve("./src/swipe.js"), loader: "exports?swipe" }] } }; if(process.env.NODE_ENV != 'production'){ console.log("development enviroment..."); // config.addVendor("react", // path.resolve(node_modules, 'react/dist/react-with-addons.js')); // config.addVendor("react-dom", // path.resolve(node_modules,'react-dom/dist/react-dom.js' )); config.entry.app.unshift("webpack/hot/dev-server"); config.entry.app.unshift('webpack-dev-server/client?http://0.0.0.0:8080'); config.addLoader({ test: /\.css$/, loader: "style!css" }); config.addLoader({ test: /\.less$/, loader: "style!css!less" }); config.addPlugin( new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') })); }else{ console.log("production enviroment..."); config.addLoader({ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") }); config.addLoader({ test: /\.less$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader", "less-loader") }); config.addPlugin( new ExtractTextPlugin("css/app.css") ); config.addPlugin( new webpack.optimize.UglifyJsPlugin({ comments: false, warnings: false })); } module.exports = config;