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

[GAPRINDASHVILI] Backport Webpack related changes #4059

Merged
merged 10 commits into from Jun 6, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 30 additions & 2 deletions .babelrc
@@ -1,5 +1,33 @@
{
"presets": [
["env", { "modules": false } ]
]
[
"env",
{
"targets": {
"browsers": [
"> 1%",
"last 2 versions",
"Firefox ESR",
"IE 10",
"IE 11"
]
}
}
],
"react",
"es2015",
"stage-1"
],
"plugins": [
"add-module-exports",
"transform-class-properties",
"transform-export-extensions",
"transform-object-rest-spread",
"transform-object-assign"
],
"env": {
"test": {
"plugins": ["transform-es2015-modules-commonjs"]
}
}
}
1 change: 0 additions & 1 deletion .eslintrc.json
@@ -1,6 +1,5 @@
{
"root": true,
"installedESLint": true,
"env": {
"browser": true,
"jquery": true
Expand Down
2 changes: 0 additions & 2 deletions config/webpack/configuration.js
Expand Up @@ -7,7 +7,6 @@ const { readFileSync } = require('fs')
const { execSync } = require('child_process')

const configPath = resolve('config', 'webpacker.yml')
const loadersDir = join(__dirname, 'loaders')
const settings = safeLoad(readFileSync(configPath), 'utf8')[env.NODE_ENV]

const { output: outputRoot, engines } = require('./paths.json');
Expand All @@ -33,7 +32,6 @@ const output = {
module.exports = {
settings,
env,
loadersDir,
output,
engines,
}
37 changes: 37 additions & 0 deletions config/webpack/loaders.js
@@ -0,0 +1,37 @@
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const { env, publicPath } = require('./configuration.js')


module.exports = [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
query: {
presets: ['react'],
},
},

{
test: /\.(scss|sass|css)$/i,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{ loader: 'css-loader', options: { minimize: env.NODE_ENV === 'production' } },
{ loader: 'postcss-loader', options: { sourceMap: true } },
'resolve-url-loader',
{ loader: 'sass-loader', options: { sourceMap: true } }
]
})
},

{
test: /\.(jpg|jpeg|png|gif|svg|eot|ttf|woff|woff2)$/i,
use: [{
loader: 'file-loader',
options: {
publicPath,
name: env.NODE_ENV === 'production' ? '[name]-[hash].[ext]' : '[name].[ext]'
}
}]
},
];
4 changes: 0 additions & 4 deletions config/webpack/loaders/angular.js

This file was deleted.

12 changes: 0 additions & 12 deletions config/webpack/loaders/assets.js

This file was deleted.

5 changes: 0 additions & 5 deletions config/webpack/loaders/babel.js

This file was deleted.

4 changes: 0 additions & 4 deletions config/webpack/loaders/coffee.js

This file was deleted.

9 changes: 0 additions & 9 deletions config/webpack/loaders/erb.js

This file was deleted.

15 changes: 0 additions & 15 deletions config/webpack/loaders/sass.js

This file was deleted.

25 changes: 9 additions & 16 deletions config/webpack/shared.js
Expand Up @@ -10,10 +10,12 @@ const { sync } = require('glob')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const ManifestPlugin = require('webpack-manifest-plugin')
const extname = require('path-complete-extname')
const { env, settings, output, loadersDir, engines } = require('./configuration.js')
const { env, settings, output, engines } = require('./configuration.js')
const loaders = require('./loaders.js')

const extensionGlob = `**/*{${settings.extensions.join(',')}}*` // */
const entryPath = join(settings.source_path, settings.source_entry_path)

let packPaths = {}

Object.keys(engines).forEach(function(k) {
Expand All @@ -39,33 +41,24 @@ module.exports = {
},

module: {
rules: sync(join(loadersDir, '*.js')).map(loader => require(loader))
rules: loaders,
},

plugins: [
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
new ExtractTextPlugin(env.NODE_ENV === 'production' ? '[name]-[hash].css' : '[name].css'),

// Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)@angular/,
resolve(__dirname, '../../'), // location of your src
{} // a map of your routes
),

new ManifestPlugin({
publicPath: output.publicPath,
writeToFileEmit: true
})
writeToFileEmit: true,
}),
],

resolve: {
extensions: settings.extensions,
modules: [
resolve(settings.source_path),
'node_modules'
]
modules: [resolve(settings.source_path)].concat(
Object.keys(engines).map(key => engines[key]).map(engine => `${engine}/node_modules`)
),
},

resolveLoader: {
Expand Down
2 changes: 0 additions & 2 deletions config/webpacker.yml
Expand Up @@ -6,8 +6,6 @@ default: &default
public_output_path: packs

extensions:
- .coffee
- .erb
- .js
- .jsx
- .ts
Expand Down
26 changes: 11 additions & 15 deletions package.json
Expand Up @@ -17,30 +17,29 @@
},
"homepage": "https://github.com/ManageIQ/manageiq#readme",
"dependencies": {
"@angular/common": "~4.0.3",
"@angular/compiler": "~4.0.3",
"@angular/core": "~4.0.3",
"@angular/platform-browser": "~4.0.3",
"@angular/platform-browser-dynamic": "~4.0.3",
"base64-js": "~1.2.3",
"core-js": "~2.4.1",
"rxjs": "~5.3.0",
"text-encoder-lite": "git://github.com/coolaj86/TextEncoderLite.git#e1e031b",
"ui-select": "0.19.8",
"zone.js": "~0.8.5"
"ui-select": "0.19.8"
},
"devDependencies": {
"autoprefixer": "~6.7.7",
"babel-core": "~6.24.1",
"babel-eslint": "~6.0.4",
"babel-loader": "~7.0",
"babel-plugin-add-module-exports": "~0.2.1",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-class-properties": "~6.24.1",
"babel-plugin-transform-es2015-modules-commonjs": "~6.26.2",
"babel-plugin-transform-export-extensions": "~6.22.0",
"babel-plugin-transform-object-assign": "~6.22.0",
"babel-plugin-transform-object-rest-spread": "~6.26.0",
"babel-polyfill": "^6.23.0",
"babel-preset-env": "~1.4.0",
"babel-preset-env": "~1.7.0",
"babel-preset-es2015": "~6.24.1",
"babel-preset-react": "~6.24.1",
"babel-preset-stage-1": "~6.24.1",
"bower-locker": "~1.0.7",
"coffee-loader": "~0.7.3",
"coffee-script": "~1.12.5",
"compression-webpack-plugin": "~0.4.0",
"css-loader": "~0.28.0",
"eslint": "~3.9.1",
Expand All @@ -61,12 +60,9 @@
"postcss-loader": "~1.3.3",
"postcss-smart-import": "~0.6.11",
"precss": "~1.4.0",
"rails-erb-loader": "~5.0.0",
"resolve-url-loader": "^2.0.2",
"sass-loader": "~6.0.3",
"style-loader": "~0.16.1",
"ts-loader": "~2.0.3",
"typescript": "~2.2.2",
"webpack": "~3.2.0",
"webpack-dev-server": "~2.4.2",
"webpack-manifest-plugin": "~1.1.0",
Expand Down