@razerspine/webpack-core 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,14 @@
1
- import { LoaderType } from '../types/loader-type';
2
- export declare function createBaseConfig(options: {
3
- root: string;
4
- env: LoaderType;
5
- templates?: {
6
- entry?: string;
7
- };
8
- }): {
9
- mode: import("..").ModeType;
10
- context: string;
1
+ import { ModeType } from '../types/mode-type';
2
+ import { ConfigOptionType } from '../types/config-option-type';
3
+ export declare function createBaseConfig(options: ConfigOptionType): {
4
+ mode: ModeType;
5
+ /**
6
+ * IMPORTANT:
7
+ * Explicit empty entry to prevent webpack default './src'
8
+ * PugPlugin controls entry points
9
+ */
10
+ entry: {};
11
11
  output: {
12
- path: string;
13
12
  clean: boolean;
14
13
  };
15
14
  module: {
@@ -1,39 +1,39 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.createBaseConfig = createBaseConfig;
7
- const path_1 = __importDefault(require("path"));
8
4
  const assets_1 = require("../loaders/assets");
9
5
  const scripts_1 = require("../loaders/scripts");
10
6
  const styles_1 = require("../loaders/styles");
11
7
  const templates_1 = require("../loaders/templates");
12
8
  function createBaseConfig(options) {
13
- var _a;
14
- const { root, env } = options;
9
+ var _a, _b;
10
+ const mode = (_a = options.mode) !== null && _a !== void 0 ? _a : 'development';
15
11
  return {
16
- mode: env.mode,
17
- context: root,
12
+ mode,
13
+ /**
14
+ * IMPORTANT:
15
+ * Explicit empty entry to prevent webpack default './src'
16
+ * PugPlugin controls entry points
17
+ */
18
+ entry: {},
18
19
  output: {
19
- path: path_1.default.join(root, 'dist'),
20
- clean: true
20
+ clean: true,
21
21
  },
22
22
  module: {
23
23
  rules: [
24
24
  (0, assets_1.assetsLoader)(),
25
- (0, scripts_1.scriptsLoader)(env),
26
- (0, styles_1.stylesLoader)(env)
27
- ]
25
+ (0, scripts_1.scriptsLoader)(options),
26
+ (0, styles_1.stylesLoader)(options),
27
+ ],
28
28
  },
29
29
  plugins: [
30
30
  ...(0, templates_1.templatesLoader)({
31
- entry: (_a = options.templates) === null || _a === void 0 ? void 0 : _a.entry,
32
- mode: env.mode
33
- })
31
+ entry: (_b = options.templates) === null || _b === void 0 ? void 0 : _b.entry,
32
+ mode,
33
+ }),
34
34
  ],
35
35
  resolve: {
36
- extensions: ['.ts', '.tsx', '.js', '.json']
37
- }
36
+ extensions: ['.ts', '.tsx', '.js', '.json'],
37
+ },
38
38
  };
39
39
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createBaseConfig } from './config/base';
2
2
  export { createDevConfig } from './config/dev';
3
3
  export { createProdConfig } from './config/prod';
4
- export * from './types/loader-type';
5
4
  export * from './types/mode-type';
6
5
  export * from './types/script-type';
7
6
  export * from './types/style-type';
7
+ export * from './types/config-option-type';
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var dev_1 = require("./config/dev");
21
21
  Object.defineProperty(exports, "createDevConfig", { enumerable: true, get: function () { return dev_1.createDevConfig; } });
22
22
  var prod_1 = require("./config/prod");
23
23
  Object.defineProperty(exports, "createProdConfig", { enumerable: true, get: function () { return prod_1.createProdConfig; } });
24
- __exportStar(require("./types/loader-type"), exports);
25
24
  __exportStar(require("./types/mode-type"), exports);
26
25
  __exportStar(require("./types/script-type"), exports);
27
26
  __exportStar(require("./types/style-type"), exports);
27
+ __exportStar(require("./types/config-option-type"), exports);
@@ -1,5 +1,5 @@
1
- import { LoaderType } from '../types/loader-type';
2
- export declare function scriptsLoader(env: LoaderType): {
1
+ import { ConfigOptionType } from '../types/config-option-type';
2
+ export declare function scriptsLoader(env: ConfigOptionType): {
3
3
  test: RegExp;
4
4
  exclude: RegExp;
5
5
  use: {
@@ -2,21 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.scriptsLoader = scriptsLoader;
4
4
  function scriptsLoader(env) {
5
- if (env.script === 'ts') {
5
+ if (env.scripts === 'ts') {
6
6
  return {
7
7
  test: /\.ts$/,
8
8
  exclude: /node_modules/,
9
9
  use: {
10
10
  loader: 'ts-loader',
11
11
  options: {
12
- transpileOnly: env.mode === 'development'
13
- }
14
- }
12
+ transpileOnly: env.mode === 'development',
13
+ },
14
+ },
15
15
  };
16
16
  }
17
17
  return {
18
18
  test: /\.m?js$/,
19
19
  exclude: /node_modules/,
20
- use: 'babel-loader'
20
+ use: 'babel-loader',
21
21
  };
22
22
  }
@@ -1,5 +1,5 @@
1
- import { LoaderType } from '../types/loader-type';
2
- export declare function stylesLoader(env: LoaderType): {
1
+ import { ConfigOptionType } from '../types/config-option-type';
2
+ export declare function stylesLoader(env: ConfigOptionType): {
3
3
  test: RegExp;
4
4
  use: (string | {
5
5
  loader: string;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stylesLoader = stylesLoader;
4
4
  function stylesLoader(env) {
5
- const isLess = env.style === 'less';
5
+ const isLess = env.styles === 'less';
6
6
  return {
7
7
  test: isLess ? /\.(css|less)$/ : /\.(css|scss|sass)$/,
8
8
  use: [
@@ -19,13 +19,13 @@ function templatesLoader(options) {
19
19
  js: {
20
20
  filename: options.mode === 'production'
21
21
  ? 'js/[name].[contenthash:8].js'
22
- : 'js/[name].js'
22
+ : 'js/[name].js',
23
23
  },
24
24
  css: {
25
25
  filename: options.mode === 'production'
26
26
  ? 'css/[name].[contenthash:8].css'
27
- : 'css/[name].css'
28
- }
29
- })
27
+ : 'css/[name].css',
28
+ },
29
+ }),
30
30
  ];
31
31
  }
@@ -1,8 +1,11 @@
1
1
  import { ModeType } from './mode-type';
2
- import { StyleType } from './style-type';
3
2
  import { ScriptType } from './script-type';
4
- export interface LoaderType {
3
+ import { StyleType } from './style-type';
4
+ export type ConfigOptionType = {
5
5
  mode: ModeType;
6
- script: ScriptType;
7
- style: StyleType;
8
- }
6
+ scripts: ScriptType;
7
+ styles: StyleType;
8
+ templates: {
9
+ entry: string;
10
+ };
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razerspine/webpack-core",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Core webpack config and loaders for starter templates",
5
5
  "license": "ISC",
6
6
  "author": "Razerspine",