Webpack extracting raw javascript from ts-loader
up vote
0
down vote
favorite
I am attempting to compile a specific file with ts-loader, but I need to emit it right after the transpilation step without additional webpack module junk. The reason is that this is a config file and must remain readable. Other .ts files are handled in different webpack target.
Until now I was using tsc directly, but I need to wrap webpack around it so I can add it to the rest of our webpack targets.
I tried to work around this with file-loader, resulting in one correct file being generated by tsc and another junk file being generated by webpack. After searching for "webpack disable output" I stumbled upon DisableOutputWebpackPlugin, which certainly does work, but does not let tsc emit either.
I have also tried ExtractTextPlugin, but it did not work properly, so I quickly gave up on it.
webpack.config-config.js
module.exports =
entry: "./src/ts/config.ts",
mode: "production",
module:
rules: [
test: /.ts$/,
use: [
loader: "file-loader",
options:
name: "../config.js"
,
loader: "ts-loader",
options:
configFile: "tsconfig-config.json"
]
]
,
plugins: [
new DisableOutputWebpackPlugin()
]
;
tsconfig-config.json
"compilerOptions":
"module": "commonjs",
"target": "es5",
"noImplicitUseStrict": true
,
"exclude": ,
"include": ["./src/ts/config.ts"]
Am I approaching this the wrong way?
typescript webpack webpack-4 tsc
add a comment |
up vote
0
down vote
favorite
I am attempting to compile a specific file with ts-loader, but I need to emit it right after the transpilation step without additional webpack module junk. The reason is that this is a config file and must remain readable. Other .ts files are handled in different webpack target.
Until now I was using tsc directly, but I need to wrap webpack around it so I can add it to the rest of our webpack targets.
I tried to work around this with file-loader, resulting in one correct file being generated by tsc and another junk file being generated by webpack. After searching for "webpack disable output" I stumbled upon DisableOutputWebpackPlugin, which certainly does work, but does not let tsc emit either.
I have also tried ExtractTextPlugin, but it did not work properly, so I quickly gave up on it.
webpack.config-config.js
module.exports =
entry: "./src/ts/config.ts",
mode: "production",
module:
rules: [
test: /.ts$/,
use: [
loader: "file-loader",
options:
name: "../config.js"
,
loader: "ts-loader",
options:
configFile: "tsconfig-config.json"
]
]
,
plugins: [
new DisableOutputWebpackPlugin()
]
;
tsconfig-config.json
"compilerOptions":
"module": "commonjs",
"target": "es5",
"noImplicitUseStrict": true
,
"exclude": ,
"include": ["./src/ts/config.ts"]
Am I approaching this the wrong way?
typescript webpack webpack-4 tsc
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am attempting to compile a specific file with ts-loader, but I need to emit it right after the transpilation step without additional webpack module junk. The reason is that this is a config file and must remain readable. Other .ts files are handled in different webpack target.
Until now I was using tsc directly, but I need to wrap webpack around it so I can add it to the rest of our webpack targets.
I tried to work around this with file-loader, resulting in one correct file being generated by tsc and another junk file being generated by webpack. After searching for "webpack disable output" I stumbled upon DisableOutputWebpackPlugin, which certainly does work, but does not let tsc emit either.
I have also tried ExtractTextPlugin, but it did not work properly, so I quickly gave up on it.
webpack.config-config.js
module.exports =
entry: "./src/ts/config.ts",
mode: "production",
module:
rules: [
test: /.ts$/,
use: [
loader: "file-loader",
options:
name: "../config.js"
,
loader: "ts-loader",
options:
configFile: "tsconfig-config.json"
]
]
,
plugins: [
new DisableOutputWebpackPlugin()
]
;
tsconfig-config.json
"compilerOptions":
"module": "commonjs",
"target": "es5",
"noImplicitUseStrict": true
,
"exclude": ,
"include": ["./src/ts/config.ts"]
Am I approaching this the wrong way?
typescript webpack webpack-4 tsc
I am attempting to compile a specific file with ts-loader, but I need to emit it right after the transpilation step without additional webpack module junk. The reason is that this is a config file and must remain readable. Other .ts files are handled in different webpack target.
Until now I was using tsc directly, but I need to wrap webpack around it so I can add it to the rest of our webpack targets.
I tried to work around this with file-loader, resulting in one correct file being generated by tsc and another junk file being generated by webpack. After searching for "webpack disable output" I stumbled upon DisableOutputWebpackPlugin, which certainly does work, but does not let tsc emit either.
I have also tried ExtractTextPlugin, but it did not work properly, so I quickly gave up on it.
webpack.config-config.js
module.exports =
entry: "./src/ts/config.ts",
mode: "production",
module:
rules: [
test: /.ts$/,
use: [
loader: "file-loader",
options:
name: "../config.js"
,
loader: "ts-loader",
options:
configFile: "tsconfig-config.json"
]
]
,
plugins: [
new DisableOutputWebpackPlugin()
]
;
tsconfig-config.json
"compilerOptions":
"module": "commonjs",
"target": "es5",
"noImplicitUseStrict": true
,
"exclude": ,
"include": ["./src/ts/config.ts"]
Am I approaching this the wrong way?
typescript webpack webpack-4 tsc
typescript webpack webpack-4 tsc
edited Nov 8 at 19:29
asked Nov 8 at 19:14
Jogurtoz
12
12
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214662%2fwebpack-extracting-raw-javascript-from-ts-loader%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown