Skip to content

Commit

Permalink
Merge pull request #21 from statisticsnorway/feature/minor-dependency…
Browse files Browse the repository at this point in the history
…-updates

Webpack 3 upgrade and dependency patches
  • Loading branch information
runejo authored Apr 4, 2022
2 parents bbcd719 + 15c8ff5 commit ed24460
Show file tree
Hide file tree
Showing 6 changed files with 26,178 additions and 41,434 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"goToUrl": true,
"waitUntilIsElementPresent": true,
"sinon": true,
define: true
"define": true
},

"env": {
Expand Down
95 changes: 52 additions & 43 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,43 @@ require('babel-polyfill');

const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');

const CopyWebpackPlugin = require('copy-webpack-plugin');

// App files location
const PATHS = {
app: path.resolve(__dirname, '../src/js'),
styles: path.resolve(__dirname, '../src/styles'),
images: path.resolve(__dirname, '../src/images'),
static: path.resolve(__dirname, '../src/static'),
build: path.resolve(__dirname, '../build')
app: path.resolve(__dirname, '../src/js'),
styles: path.resolve(__dirname, '../src/styles'),
images: path.resolve(__dirname, '../src/images'),
static: path.resolve(__dirname, '../src/static'),
build: path.resolve(__dirname, '../build')
};

const plugins = [
new CopyWebpackPlugin([
{
from: PATHS.images,
to: 'images'
},
{
from: PATHS.static,
to: 'static'
}
]),
new CopyWebpackPlugin([
{
from: PATHS.images,
to: 'images'
},
{
from: PATHS.static,
to: 'static'
}
]),
// Shared code
new webpack.optimize.CommonsChunkPlugin('vendor', 'js/vendor.bundle.js'),
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'js/vendor.bundle.js' }),
// Avoid publishing files when compilation fails
new webpack.NoErrorsPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
__DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false'))
}),
new webpack.optimize.OccurenceOrderPlugin()
new webpack.LoaderOptionsPlugin({
debug: true
})
];

const sassLoaders = [
'style-loader',
'css-loader?sourceMap',
'postcss-loader',
'sass-loader?outputStyle=expanded'
];

var config = {
env : process.env.NODE_ENV,
module.exports = {
entry: {
app: path.resolve(PATHS.app, 'main.js'),
vendor: ['babel-polyfill', 'react']
Expand All @@ -61,22 +54,45 @@ var config = {
},
resolve: {
// We can now require('file') instead of require('file.jsx')
extensions: ['', '.js', '.jsx', '.scss']
extensions: ['.js', '.jsx', '.scss']
},
module: {
loaders: [
rules: [
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel'],
loaders: ['react-hot-loader', 'babel-loader'],
include: PATHS.app
},
{
test: /\.scss$/,
loader: sassLoaders.join('!')
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader'
},
{
loader: 'postcss-loader'
},
{
loader: 'sass-loader',
options: {
outputStyle: 'expanded'
}
}
]
},
{
test: /\.css$/,
loader: 'style-loader!css-loader!postcss-loader'
use: [
{
loader: 'css-loader'
},
{
loader: 'postcss-loader'
}
]
},
// Inline base64 URLs for <=8k images, direct URLs for the rest
{
Expand All @@ -86,14 +102,10 @@ var config = {
]
},
plugins: plugins,
postcss: function () {
return [autoprefixer({
browsers: ['last 2 versions']
})];
},
devtool: 'eval-source-map',
devServer: {
contentBase: path.resolve(__dirname, '../src'),
historyApiFallback: true,
historyApiFallback: true,
port: 3000
// proxy: {
// '/api/*': {
Expand All @@ -104,8 +116,5 @@ var config = {
// }
// }
// }
},debug:true,
devtool: 'eval-source-map'
}
};

module.exports = config;
59 changes: 36 additions & 23 deletions config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ require('babel-polyfill');

const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');

const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
Expand All @@ -28,16 +27,15 @@ const plugins = [
}
]),
// Shared code
new webpack.optimize.CommonsChunkPlugin('vendor', 'js/vendor.bundle.js'),
new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'js/vendor.bundle.js' }),
// Avoid publishing files when compilation fails
new webpack.NoErrorsPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
__DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false'))
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
Expand All @@ -46,12 +44,6 @@ const plugins = [
new ExtractTextPlugin('css/app.css', { allChunks: true })
];

const sassLoaders = [
'css-loader?sourceMap',
'postcss-loader',
'sass-loader?outputStyle=compressed'
];

module.exports = {
entry: {
app: path.resolve(PATHS.app, 'main.js'),
Expand All @@ -64,28 +56,54 @@ module.exports = {
publicPath: '/klass-ssb-no/'
},
stats: {
colors: true
colors: true,
reasons: true
},
resolve: {
// We can now require('file') instead of require('file.jsx')
extensions: ['', '.js', '.jsx', '.scss']
extensions: ['.js', '.jsx', '.scss']
},
module: {
noParse: /\.min\.js$/,
loaders: [
rules: [
{
test: /\.jsx?$/,
loaders: ['react-hot', 'babel'],
loaders: ['react-hot-loader', 'babel-loader'],
include: PATHS.app
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!'))
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader'
},
{
loader: 'postcss-loader'
},
{
loader: 'sass-loader',
options: {
outputStyle: 'compressed'
}
}
]
})
},
{
test: /\.css$/,
// include: PATHS.styles,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader'
},
{
loader: 'postcss-loader'
}
]
})
},
// Inline base64 URLs for <=8k images, direct URLs for the rest
{
Expand All @@ -99,10 +117,5 @@ module.exports = {
]
},
plugins: plugins,
postcss: function () {
return [autoprefixer({
browsers: ['last 2 versions']
})];
},
devtool: 'source-map'
};
Loading

0 comments on commit ed24460

Please sign in to comment.