Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-44298: Resolve serving issues #89

Merged
merged 4 commits into from
Aug 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = {
useEslintrc: false
},
// @remove-on-eject-end
loader: 'eslint-loader',
loader: require.resolve('eslint-loader'),
include: process.cwd(),
exclude: /node_modules/
},
Expand All @@ -117,7 +117,7 @@ module.exports = {
// Image filetypes get excluded to be handled by the url-loader later.
{
exclude: /\.(html|js|jsx|css|less|ejs|json|bmp|gif|jpe?g|png|svg)$/,
loader: 'file-loader',
loader: require.resolve('file-loader'),
options: {
name: '[path][name].[ext]'
}
Expand All @@ -127,7 +127,7 @@ module.exports = {
// Assets bigger than the limit will fallback to the file-loader.
{
test: /\.(bmp|gif|jpe?g|png|svg)$/,
loader: 'url-loader',
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: '[path][name].[ext]'
Expand All @@ -137,7 +137,7 @@ module.exports = {
{
test: /\.(js|jsx)$/,
exclude: /node_modules.(?!@enact)/,
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: {
// @remove-on-eject-begin
babelrc: false,
Expand All @@ -162,10 +162,10 @@ module.exports = {
test: /\.(c|le)ss$/,
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
fallback: require.resolve('style-loader'),
use: [
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
options: {
importLoaders: 2,
modules: true,
Expand All @@ -174,7 +174,7 @@ module.exports = {
}
},
{
loader: 'postcss-loader',
loader: require.resolve('postcss-loader'),
options: {
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
sourceMap: true,
Expand All @@ -186,7 +186,8 @@ module.exports = {
'last 4 versions',
'Firefox ESR',
'not ie < 9' // React doesn't support IE8 anyway.
]
],
flexbox: 'no-2009'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a prop that was accidentally omitted last release (change already exists within production config). Just brings up to parity.

}),
// Fix and adjust for known flexbox issues
// See https://github.com/philipwalton/flexbugs
Expand All @@ -195,7 +196,7 @@ module.exports = {
}
},
{
loader: 'less-loader',
loader: require.resolve('less-loader'),
options: {
sourceMap: true,
// If resolution independence options are specified, use the LESS plugin.
Expand All @@ -209,7 +210,7 @@ module.exports = {
// Currently maps the toolset to window.ReactPerf.
{
test: reactPerf,
loader: 'expose-loader',
loader: require.resolve('expose-loader'),
options: 'ReactPerf'
}
// ** STOP ** Are you adding a new loader?
Expand Down
16 changes: 8 additions & 8 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {
useEslintrc: false
},
// @remove-on-eject-end
loader: 'eslint-loader',
loader: require.resolve('eslint-loader'),
include: process.cwd(),
exclude: /node_modules/
},
Expand All @@ -107,7 +107,7 @@ module.exports = {
// Image filetypes get excluded to be handled by the url-loader later.
{
exclude: /\.(html|js|jsx|css|less|ejs|json|bmp|gif|jpe?g|png|svg)$/,
loader: 'file-loader',
loader: require.resolve('file-loader'),
options: {
name: '[path][name].[ext]'
}
Expand All @@ -117,7 +117,7 @@ module.exports = {
// Assets bigger than the limit will fallback to the file-loader.
{
test: /\.(bmp|gif|jpe?g|png|svg)$/,
loader: 'url-loader',
loader: require.resolve('url-loader'),
options: {
limit: 10000,
name: '[path][name].[ext]'
Expand All @@ -127,7 +127,7 @@ module.exports = {
{
test: /\.(js|jsx)$/,
exclude: /node_modules.(?!@enact)/,
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
// @remove-on-eject-begin
options: {
babelrc: false,
Expand All @@ -148,18 +148,18 @@ module.exports = {
test: /\.(c|le)ss$/,
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
fallback: require.resolve('style-loader'),
use: [
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
options: {
importLoaders: 2,
modules: true,
minimize: true
}
},
{
loader: 'postcss-loader',
loader: require.resolve('postcss-loader'),
options: {
ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options
plugins: () => [
Expand All @@ -182,7 +182,7 @@ module.exports = {
}
},
{
loader: 'less-loader',
loader: require.resolve('less-loader'),
options: {
// If resolution independence options are specified, use the LESS plugin.
plugins: ((enact.ri) ? [new LessPluginRi(enact.ri)] : [])
Expand Down
3 changes: 2 additions & 1 deletion global-cli/modifiers/util/config-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module.exports = {
if(config && config.module && config.module.rules && name) {
for(let i=0; i<config.module.rules.length; i++) {
if(config.module.rules[i].loader) {
if(config.module.rules[i].loader === name + '-loader') {
if(config.module.rules[i].loader === name + '-loader'
|| new RegExp('node_modules[/\\\\]+' + name + '-loader').test(config.module.rules[i].loader)) {
index = i;
break;
}
Expand Down
39 changes: 39 additions & 0 deletions global-cli/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,45 @@ module.exports = function(args) {

const config = hotDevServer(devConfig);

// Temporary workaround until https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/579 is fixed
const enact = require(path.resolve('./package.json')).enact || {};
const autoprefixer = require('autoprefixer');
const LessPluginRi = require('resolution-independence');
config.module.rules[4] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we "find" the index here (and below) rather than hard coding it? Might save us from accidentally breaking this without noticing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not easily given the loader name itself is dynamic generated from extract-text-plugin. If we want a more complex detection system I can implement that, though given we control the config and this is solely a serve fix for an issue actively being worked on by the webpack team, the impact potential is very very small. Probably will be removed next enact-dev update.

test: /\.(c|le)ss$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 2,
modules: true,
sourceMap: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
},
{
loader: require.resolve('postcss-loader'),
options: {
ident: 'postcss',
sourceMap: true,
plugins: () => [
autoprefixer({browsers:['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9'], flexbox:'no-2009'}),
require('postcss-flexbugs-fixes')
]
}
},
{
loader: require.resolve('less-loader'),
options: {
sourceMap: true,
plugins: ((enact.ri) ? [new LessPluginRi(enact.ri)] : [])
}
}
]
};
config.plugins.splice(2, 1);

// Warn and crash if required files are missing
if (!checkRequiredFiles([config.entry.main[config.entry.main.length-1]])) {
process.exit(1);
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"babel-preset-stage-0": "~6.24.1",
"case-sensitive-paths-webpack-plugin": "~2.1.1",
"chai": "~3.5.0",
"chalk": "~2.0.1",
"chalk": "~2.1.0",
"connect-history-api-fallback": "~1.3.0",
"console-snoop": "~0.0.2",
"console.mute": "~0.3.0",
Expand All @@ -39,12 +39,12 @@
"dirty-chai": "~1.2.2",
"enzyme": "~2.9.1",
"es6-map": "~0.1.5",
"eslint": "~4.3.0",
"eslint": "~4.4.1",
"eslint-config-enact": "~1.1.8",
"eslint-loader": "~1.9.0",
"eslint-plugin-babel": "~4.1.2",
"eslint-plugin-enact": "~0.1.3",
"eslint-plugin-react": "7.1.0",
"eslint-plugin-react": "7.2.0",
"expose-loader": "~0.7.3",
"extract-text-webpack-plugin": "~3.0.0",
"file-loader": "~0.11.2",
Expand Down Expand Up @@ -87,7 +87,7 @@
"raw-loader": "~0.5.1",
"react": "~15.6.1",
"react-addons-perf": "~15.4.2",
"react-dev-utils": "~3.0.2",
"react-dev-utils": "~3.1.1",
"react-dom": "~15.6.1",
"react-error-overlay": "~1.0.9",
"react-test-renderer": "~15.6.1",
Expand All @@ -103,9 +103,9 @@
"style-loader": "~0.18.2",
"url-loader": "~0.5.9",
"webos-meta-webpack-plugin": "~0.3.1",
"webpack": "~3.4.1",
"webpack-bundle-analyzer": "~2.8.3",
"webpack-dev-server": "~2.6.1",
"webpack": "~3.5.3",
"webpack-bundle-analyzer": "~2.9.0",
"webpack-dev-server": "~2.7.1",
"webpack-sources": "~1.0.1",
"whatwg-fetch": "~2.0.3"
}
Expand Down