Commit 1ef16083 by Ari Rizzitano

slight restructure

parent 02b508dc
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
output: {
filename: 'static/index.js',
library: 'paragon',
libraryTarget: 'umd',
},
plugins: [
new ExtractTextPlugin('static/paragon.min.css'),
],
module: {
rules: [
{
test: /\.scss|\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: 'paragon__[local]',
sourceMap: true,
minimize: true,
},
},
{
loader: 'sass-loader',
options: {
data: '@import "paragon-reset";',
includePaths: [
path.join(__dirname, '../src/utils'),
path.join(__dirname, '../node_modules'),
],
sourceMap: true,
},
},
],
}),
},
{
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
outputPath: 'static/',
},
},
],
},
};
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
output: {
filename: 'themeable/paragon.min.js',
library: 'paragon',
libraryTarget: 'umd',
},
plugins: [
new ExtractTextPlugin('themeable/paragon.min.css'),
],
module: {
rules: [
{
test: /\.scss|\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]',
sourceMap: true,
minimize: true,
},
},
{
loader: 'sass-loader',
options: {
data: '@import "paragon-reset";',
includePaths: [
path.join(__dirname, '../src/utils'),
path.join(__dirname, '../node_modules'),
],
},
},
],
}),
},
{
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
outputPath: 'themeable/',
},
},
],
},
};
...@@ -16531,23 +16531,6 @@ ...@@ -16531,23 +16531,6 @@
"strip-ansi": "3.0.1" "strip-ansi": "3.0.1"
} }
}, },
"webpack-merge": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-4.1.1.tgz",
"integrity": "sha512-geQsZ86YkXOVOjvPC5yv3JSNnL6/X3Kzh935AQ/gJNEYXEfJDQFu/sdFuktS9OW2JcH/SJec8TGfRdrpHshH7A==",
"dev": true,
"requires": {
"lodash": "4.17.4"
},
"dependencies": {
"lodash": {
"version": "4.17.4",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=",
"dev": true
}
}
},
"webpack-sources": { "webpack-sources": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.2.tgz", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.2.tgz",
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
"name": "@edx/paragon", "name": "@edx/paragon",
"version": "0.0.0-development", "version": "0.0.0-development",
"description": "Accessible, responsive UI component library based on Bootstrap.", "description": "Accessible, responsive UI component library based on Bootstrap.",
"main": "themeable/paragon.min.js", "main": "themeable/index.js",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/edx/paragon.git" "url": "https://github.com/edx/paragon.git"
}, },
"scripts": { "scripts": {
"build": "NODE_ENV=production webpack --config config/webpack.config.js", "build": "NODE_ENV=production webpack --config webpack.config.js",
"build-storybook": "build-storybook", "build-storybook": "build-storybook",
"commitmsg": "commitlint -e $GIT_PARAMS", "commitmsg": "commitlint -e $GIT_PARAMS",
"coveralls": "cat ./coverage/lcov.info | coveralls", "coveralls": "cat ./coverage/lcov.info | coveralls",
...@@ -79,8 +79,7 @@ ...@@ -79,8 +79,7 @@
"uglifyjs-webpack-plugin": "^1.1.4", "uglifyjs-webpack-plugin": "^1.1.4",
"webpack": "^3.0.0", "webpack": "^3.0.0",
"webpack-build-notifier": "^0.1.16", "webpack-build-notifier": "^0.1.16",
"webpack-dev-server": "^2.4.4", "webpack-dev-server": "^2.4.4"
"webpack-merge": "^4.1.0"
}, },
"jest": { "jest": {
"setupFiles": [ "setupFiles": [
......
const path = require('path'); const path = require('path');
const merge = require('webpack-merge');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const staticConfig = require('./webpack.static.config'); // we build the library for two different build targets:
const themeableConfig = require('./webpack.themeable.config'); // static (with scoped styles) and themeable (with stock,
// overrideable classnames)
const targetProperties = [{
baseDirectory: 'static',
localIdentName: 'paragon__[local]',
},
{
baseDirectory: 'themeable',
localIdentName: '[local]',
}];
const commonConfig = { module.exports = targetProperties.map(config => ({
devtool: 'source-map', devtool: 'source-map',
entry: { entry: {
paragon: path.resolve('./src/index.js'), paragon: path.resolve('./src/index.js'),
}, },
output: {
filename: `${config.baseDirectory}/index.js`,
library: 'paragon',
libraryTarget: 'umd',
},
resolve: { resolve: {
extensions: ['.js', '.jsx'], extensions: ['.js', '.jsx'],
}, },
...@@ -17,6 +31,7 @@ const commonConfig = { ...@@ -17,6 +31,7 @@ const commonConfig = {
new UglifyJsPlugin({ new UglifyJsPlugin({
sourceMap: true, sourceMap: true,
}), }),
new ExtractTextPlugin(`${config.baseDirectory}/paragon.min.css`),
], ],
module: { module: {
rules: [ rules: [
...@@ -33,6 +48,40 @@ const commonConfig = { ...@@ -33,6 +48,40 @@ const commonConfig = {
{ loader: 'source-map-loader' }, { loader: 'source-map-loader' },
], ],
}, },
{
test: /\.scss|\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: config.localIdentName,
sourceMap: true,
minimize: true,
},
},
{
loader: 'sass-loader',
options: {
data: '@import "paragon-reset";',
includePaths: [
path.join(__dirname, './src/utils'),
path.join(__dirname, './node_modules'),
],
sourceMap: true,
},
},
],
}),
},
{
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'file-loader',
options: {
outputPath: `${config.baseDirectory}/`,
},
},
], ],
}, },
externals: [{ externals: [{
...@@ -59,9 +108,4 @@ const commonConfig = { ...@@ -59,9 +108,4 @@ const commonConfig = {
amd: 'react-transition-group', amd: 'react-transition-group',
}, },
}], }],
}; }));
module.exports = [
merge(commonConfig, staticConfig),
merge(commonConfig, themeableConfig),
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment