Skip to content

Instantly share code, notes, and snippets.

@hopewise
Last active August 16, 2018 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hopewise/1aa9459b1558d4f3c540a7f53e2e76fa to your computer and use it in GitHub Desktop.
Save hopewise/1aa9459b1558d4f3c540a7f53e2e76fa to your computer and use it in GitHub Desktop.
React JS , mobx , GraphQL , apollo client, webpack-dev-server writes file to desk, load .graphql files separately
{
"presets": [
"react",
"es2015",
"stage-1"
],
"plugins": ["transform-decorators-legacy", "transform-class-properties", "inline-import-graphql-ast"]
}
{
"name": "vrp-ui",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^1.0.0",
"ajv": "^6.5.0",
"apollo-boost": "^0.1.6",
"apollo-cache-inmemory": "^1.2.1",
"apollo-client": "^2.3.1",
"apollo-client-preset": "^1.0.8",
"apollo-link": "^1.2.2",
"apollo-link-http": "^1.5.4",
"axios": "^0.18.0",
"babel-plugin-inline-import-graphql-ast": "^2.4.0",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"mobx": "^4.3.0",
"mobx-react": "^5.1.2",
"mobx-react-devtools": "^5.0.1",
"react": "^16.3.2",
"react-apollo": "^2.1.4",
"react-dom": "^16.3.2",
"react-google-maps": "^9.4.5",
"react-scripts": "1.1.4",
"semantic-ui-react": "^0.80.0",
"semantic-ui-css": "^2.3.3"
},
"scripts": {
"watch": "cra-build-watch",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"dev": "webpack-dev-server --content-base src --inline --hot"
},
"devDependencies": {
"babel-core": "^6.17.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-mobx": "^1.0.2",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-1": "^6.5.0",
"cra-build-watch": "^1.0.1",
"webpack": "^3.5.5",
"webpack-dev-server": "^2.7.1",
"webpack-graphql-loader": "^0.1.2",
"webpack-cli": "^2.0.9",
"write-file-webpack-plugin": "^4.3.2"
}
}
var debug = true;//process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
var WriteFilePlugin = require('write-file-webpack-plugin');
module.exports = {
context: path.join(__dirname, "src"),
devtool: debug ? "inline-sourcemap" : null,
entry: "./index.js",
module: {
rules: [
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
],
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: { presets: ['es2015', 'react'], plugins: ["transform-decorators-legacy", "transform-class-properties"] }
},
{ test: /\.css$/, loader: "style-loader!css-loader" },
]
},
output: {
path: path.join(__dirname, "./build/js"),
filename: "bundle.js"
},
plugins: debug ? [
new WriteFilePlugin(),
] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false })
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment