-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: convert browserify to webpack, fixes #976
- Loading branch information
Showing
34 changed files
with
1,495 additions
and
1,377 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = ({ file, options, env }) => ({ | ||
plugins: { | ||
'postcss-import': { root: file.dirname }, | ||
// contains autoprefixer, etc | ||
'postcss-preset-env': options['postcss-preset-env'] | ||
? options['postcss-preset-env'] | ||
: false, | ||
cssnano: process.env.NODE_ENV === 'production' ? options.cssnano : false, | ||
}, | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); | ||
|
||
const isDev = process.env.NODE_ENV === 'development'; | ||
|
||
const relPath = (...args) => path.resolve(__dirname, ...args); | ||
const rootPath = (...args) => relPath('../', ...args); | ||
|
||
const resultConfig = { | ||
mode: process.env.NODE_ENV, | ||
entry: Boolean(isDev && process.env.WEBPACK_SERVE) | ||
? [ | ||
'react-hot-loader/patch', // activate HMR for React | ||
'webpack-dev-server/client?http://localhost:8080', // bundle the client for webpack-dev-server and connect to the provided endpoint | ||
'webpack/hot/only-dev-server', // bundle the client for hot reloading, only- means to only hot reload for successful updates | ||
'./index.js', // the entry point of our app | ||
] | ||
: './index.js', | ||
context: rootPath('src'), | ||
output: { | ||
path: rootPath(), | ||
library: 'GraphiQL', | ||
libraryTarget: 'window', | ||
libraryExport: 'default', | ||
filename: isDev ? 'graphiql.js' : 'graphiql.min.js', | ||
}, | ||
devServer: { | ||
hot: true, | ||
// bypass simple localhost CORS restrictions by setting | ||
// these to 127.0.0.1 in /etc/hosts | ||
allowedHosts: ['local.example.com', 'graphiql.com'], | ||
}, | ||
node: { | ||
fs: 'empty', | ||
}, | ||
externals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}, | ||
module: { | ||
rules: [ | ||
// for graphql module, which uses .mjs | ||
{ | ||
type: 'javascript/auto', | ||
test: /\.mjs$/, | ||
use: [], | ||
include: /node_modules/, | ||
}, | ||
// i think we need to add another rule for | ||
// codemirror-graphql esm.js files to load | ||
{ | ||
test: /\.(js|jsx)$/, | ||
use: [{ loader: 'babel-loader' }], | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: [ | ||
{ | ||
loader: MiniCssExtractPlugin.loader, | ||
options: { | ||
hmr: isDev, | ||
}, | ||
}, | ||
'css-loader', | ||
'postcss-loader', | ||
], | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
// in order to prevent async modules for CDN builds | ||
// until we can guarantee it will work with the CDN properly | ||
// and so that graphiql.min.js can retain parity | ||
new webpack.optimize.LimitChunkCountPlugin({ | ||
maxChunks: 1, | ||
}), | ||
new HtmlWebpackPlugin({ | ||
template: relPath('index.html.ejs'), | ||
inject: 'head', | ||
filename: isDev ? 'dev.html' : 'index.html', | ||
}), | ||
new MiniCssExtractPlugin({ | ||
// Options similar to the same options in webpackOptions.output | ||
// both options are optional | ||
filename: isDev ? 'graphiql.css' : 'graphiql.min.css', | ||
chunkFilename: '[id].css', | ||
}), | ||
], | ||
resolve: { | ||
extensions: ['.mjs', '.js', '.json', '.jsx', '.css'], | ||
modules: [rootPath('node_modules'), rootPath('../', '../', 'node_modules')], | ||
}, | ||
}; | ||
|
||
const cssLoaders = [ | ||
{ | ||
loader: MiniCssExtractPlugin.loader, | ||
options: { | ||
hmr: isDev, | ||
}, | ||
}, | ||
'css-loader', | ||
]; | ||
|
||
if (!isDev) { | ||
cssLoaders.push('postcss-loader'); | ||
} | ||
|
||
resultConfig.module.rules.push(); | ||
|
||
if (process.env.ANALYZE) { | ||
resultConfig.plugins.push( | ||
new BundleAnalyzerPlugin({ | ||
analyzerMode: 'static', | ||
openAnalyzer: false, | ||
reportFilename: rootPath('coverage/analyzer/index.html'), | ||
}) | ||
); | ||
} | ||
|
||
module.exports = resultConfig; |
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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
Oops, something went wrong.